Skip to content

Commit

Permalink
0.33 compat followup (#296)
Browse files Browse the repository at this point in the history
* Drop redundant prefixes in BlockIDFlag enum variants

- #196 (comment)

* improve error message
  • Loading branch information
liamsi authored Jun 3, 2020
1 parent b881142 commit 622166b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions tendermint/src/block/commit_sig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl TryFrom<RawCommitSig> for CommitSig {

fn try_from(value: RawCommitSig) -> Result<Self, Self::Error> {
match value.block_id_flag {
BlockIDFlag::BlockIDFlagAbsent => {
BlockIDFlag::Absent => {
if value.timestamp.is_some()
&& value.timestamp.unwrap()
!= Time::parse_from_rfc3339("0001-01-01T00:00:00Z").unwrap()
Expand All @@ -53,7 +53,7 @@ impl TryFrom<RawCommitSig> for CommitSig {
}
Ok(CommitSig::BlockIDFlagAbsent)
}
BlockIDFlag::BlockIDFlagCommit => {
BlockIDFlag::Commit => {
if value.timestamp.is_none() {
Err("timestamp is missing for BlockIDFlagCommit CommitSig")
} else if value.signature.is_none() {
Expand All @@ -68,7 +68,7 @@ impl TryFrom<RawCommitSig> for CommitSig {
})
}
}
BlockIDFlag::BlockIDFlagNil => {
BlockIDFlag::Nil => {
if value.timestamp.is_none() {
Err("timestamp is missing for BlockIDFlagNil CommitSig")
} else if value.signature.is_none() {
Expand All @@ -91,7 +91,7 @@ impl From<CommitSig> for RawCommitSig {
fn from(commit: CommitSig) -> RawCommitSig {
match commit {
CommitSig::BlockIDFlagAbsent => RawCommitSig {
block_id_flag: BlockIDFlag::BlockIDFlagAbsent,
block_id_flag: BlockIDFlag::Absent,
validator_address: None,
timestamp: None,
signature: None,
Expand All @@ -101,7 +101,7 @@ impl From<CommitSig> for RawCommitSig {
timestamp,
signature,
} => RawCommitSig {
block_id_flag: BlockIDFlag::BlockIDFlagNil,
block_id_flag: BlockIDFlag::Nil,
validator_address: Some(validator_address),
timestamp: Some(timestamp),
signature: Some(signature),
Expand All @@ -111,7 +111,7 @@ impl From<CommitSig> for RawCommitSig {
timestamp,
signature,
} => RawCommitSig {
block_id_flag: BlockIDFlag::BlockIDFlagCommit,
block_id_flag: BlockIDFlag::Commit,
validator_address: Some(validator_address),
timestamp: Some(timestamp),
signature: Some(signature),
Expand Down
2 changes: 1 addition & 1 deletion tendermint/src/lite_impl/signed_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl lite::Commit for block::signed_header::SignedHeader {
if self.commit.signatures.len() != vals.validators().len() {
fail!(
Kind::ImplementationSpecific,
"pre-commit length: {} doesn't match validator length: {}",
"commit signatures count: {} doesn't match validators count: {}",
self.commit.signatures.len(),
vals.validators().len()
);
Expand Down
6 changes: 3 additions & 3 deletions tendermint/src/serializers/raw_commit_sig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ use std::str::FromStr;
#[repr(u8)]
pub enum BlockIDFlag {
/// vote is not included in the Commit.Precommits
BlockIDFlagAbsent = 1,
Absent = 1,
/// voted for the Commit.BlockID
BlockIDFlagCommit = 2,
Commit = 2,
/// voted for nil
BlockIDFlagNil = 3,
Nil = 3,
}

/// RawCommitSig struct for interim deserialization of JSON object
Expand Down

0 comments on commit 622166b

Please sign in to comment.