From ea86d865ef46c8fe442f4c85bfb4350740ab05b9 Mon Sep 17 00:00:00 2001 From: Tony Arcieri Date: Thu, 23 Jan 2020 11:44:12 -0800 Subject: [PATCH] Remove remaining non-namespaced references to `prost` ...renaming them all to `prost_amino`. This should allow us to use `prost` proper with the KMS to do proper Protobuf encoding/decoding. --- src/connection/secret_connection.rs | 2 +- src/error.rs | 10 +++++----- src/lib.rs | 2 -- src/rpc.rs | 8 ++++---- tests/integration.rs | 10 ++++------ 5 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/connection/secret_connection.rs b/src/connection/secret_connection.rs index 266f4f0..7004c63 100644 --- a/src/connection/secret_connection.rs +++ b/src/connection/secret_connection.rs @@ -12,7 +12,7 @@ use chacha20poly1305::{ aead::{generic_array::GenericArray, Aead, NewAead}, ChaCha20Poly1305, }; -use prost::{encoding::encode_varint, Message}; +use prost_amino::{encoding::encode_varint, Message}; use signatory::{ ed25519, signature::{Signature, Signer, Verifier}, diff --git a/src/error.rs b/src/error.rs index e004f6c..8b5b0c0 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,6 +1,6 @@ //! Error types -use crate::{chain, prelude::*, prost}; +use crate::{chain, prelude::*}; use abscissa_core::error::{BoxError, Context}; use std::{ any::Any, @@ -155,14 +155,14 @@ impl std::error::Error for Error { } } -impl From for Error { - fn from(other: prost::DecodeError) -> Self { +impl From for Error { + fn from(other: prost_amino::DecodeError) -> Self { ErrorKind::ProtocolError.context(other).into() } } -impl From for Error { - fn from(other: prost::EncodeError) -> Self { +impl From for Error { + fn from(other: prost_amino::EncodeError) -> Self { ErrorKind::ProtocolError.context(other).into() } } diff --git a/src/lib.rs b/src/lib.rs index 33f8b9a..112d70f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,8 +10,6 @@ compile_error!( yubihsm, ledgertm, softsign (e.g. --features=yubihsm)" ); -extern crate prost_amino as prost; - pub mod application; pub mod chain; pub mod client; diff --git a/src/rpc.rs b/src/rpc.rs index 2fc6520..417929f 100644 --- a/src/rpc.rs +++ b/src/rpc.rs @@ -3,12 +3,12 @@ // TODO: docs for everything #![allow(missing_docs)] -use crate::{ - prost::encoding::{decode_varint, encoded_len_varint}, - prost::Message, -}; use bytes::Bytes; use once_cell::sync::Lazy; +use prost_amino::{ + encoding::{decode_varint, encoded_len_varint}, + Message, +}; use sha2::{Digest, Sha256}; use std::io::{self, Error, ErrorKind, Read}; use tendermint::amino_types::*; diff --git a/tests/integration.rs b/tests/integration.rs index bd85960..ee4b9cb 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -1,10 +1,8 @@ //! KMS integration test -extern crate prost_amino as prost; - -use crate::prost::Message; use abscissa_core::prelude::warn; use chrono::{DateTime, Utc}; +use prost_amino::Message; use rand::Rng; use signatory::{ ed25519, @@ -298,13 +296,13 @@ fn test_key() -> (ed25519::PublicKey, Ed25519Signer) { } /// Extract the actual length of an amino message -pub fn extract_actual_len(buf: &[u8]) -> Result { +pub fn extract_actual_len(buf: &[u8]) -> Result { let mut buff = Cursor::new(buf); - let actual_len = prost::encoding::decode_varint(&mut buff)?; + let actual_len = prost_amino::encoding::decode_varint(&mut buff)?; if actual_len == 0 { return Ok(1); } - Ok(actual_len + (prost::encoding::encoded_len_varint(actual_len) as u64)) + Ok(actual_len + (prost_amino::encoding::encoded_len_varint(actual_len) as u64)) } #[test]