This repository has been archived by the owner on Feb 25, 2021. It is now read-only.
forked from yihuang/tendermint-rs
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update crypto-com-chain branch for the new PR request (#3)
* build(deps): update tai64 requirement from 2 to 3 (informalsystems#22) Updates the requirements on [tai64](https://github.com/iqlusioninc/crates) to permit the latest version. - [Release notes](https://github.com/iqlusioninc/crates/releases) - [Commits](iqlusioninc/crates@canonical-path/v2.0.0...tai64/3.0.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * simple_hash_from_byte_slices takes a Vec instead of slice * cargo fmt * WIP: pass in Vec<Vec<u8> instead of &Vec<Vec<u8> - work in progress as we might want to let an inner function for the recursion - also we might simply want to use From to consume (or create a Vec) instead of changing the method signature (as suggested here: informalsystems#57 (comment)) * use Vec<Vec<u8>> with inner recursion method * merge in changes of informalsystems#59 and simplify Header::hash * simplify tests: direct vector initialization instead of going through &[&[u8]] * remove obsolete comment * Further reduce boilerplate code by leveraging generics * max_gas should be i64, can be -1 * remove unneed clones * remove secret_connection * Create a trait for with a blanket impl instead of new type Thanks for the suggestion @tarcieri :-) * impl lite::Commit for commit::SignedHeader * Parse validators field in genesis api * Modify lite::Commit impl for SignedHeader to not include amino dep: - SignedVote can now be constructed without going through CanoncialVote (which is an amino-type) - modify impl to match new constructor and remove amino dep - make explicit where which types are amino_types (in vote.rs) * impl lite::ValidatorSetLookup * Add a few methods to tests and deduplicate code for fn hash of lite::ValidatorSet:: & Set - tests for lite::ValidatorSetLookup lite::ValidatorSet impl - delete `fn hash(self) -> merkle::Hash` from Set and only keep the impl of lite::ValidatorSet * implement utility traits for tendermint data types * Signing bytes need to encoded with encode_length_delimited * utilities
- Loading branch information
Showing
12 changed files
with
162 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use prost_amino::encoding::encoded_len_varint; | ||
|
||
/// Extend the original prost::Message trait with a few helper functions in order to | ||
/// reduce boiler-plate code (and without modifying the prost-amino dependency). | ||
pub trait AminoMessage: prost_amino::Message { | ||
/// Directly amino encode a prost-amino message into a freshly created Vec<u8>. | ||
/// This can be useful when passing those bytes directly to a hasher, or, | ||
/// to reduce boiler plate code when working with the encoded bytes. | ||
/// | ||
/// Warning: Only use this method, if you are in control what will be encoded. | ||
/// If there is an encoding error, this method will panic. | ||
fn bytes_vec(&self) -> Vec<u8> | ||
where | ||
Self: Sized, | ||
{ | ||
let mut res = Vec::with_capacity(self.encoded_len()); | ||
self.encode(&mut res).unwrap(); | ||
res | ||
} | ||
|
||
/// Encode prost-amino message as length delimited. | ||
/// | ||
/// Warning: Only use this method, if you are in control what will be encoded. | ||
/// If there is an encoding error, this method will panic. | ||
fn bytes_vec_length_delimited(&self) -> Vec<u8> | ||
where | ||
Self: Sized, | ||
{ | ||
let len = self.encoded_len(); | ||
let mut res = Vec::with_capacity(len + encoded_len_varint(len as u64)); | ||
self.encode_length_delimited(&mut res).unwrap(); | ||
res | ||
} | ||
} | ||
impl<M: prost_amino::Message> AminoMessage for M { | ||
// blanket impl | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.