Skip to content

Commit

Permalink
chore(proto): adjust errors
Browse files Browse the repository at this point in the history
  • Loading branch information
lklimek committed Apr 13, 2023
1 parent 5de378e commit c3a731a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
5 changes: 5 additions & 0 deletions proto/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ define_error! {
ParseLength
[ DisplayOnly<TryFromIntError> ]
| _ | { "error parsing encoded length" },

CreateCanonical
[ DisplayOnly<String> ]
| _ | { "cannot prepare canonical form: {}" },

}
}

Expand Down
10 changes: 5 additions & 5 deletions proto/src/signatures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl SignBytes for StateId {
fn sign_bytes(&self, _ctx: &SignContext) -> Result<Vec<u8>, Error> {
let mut buf = Vec::new();
self.encode_length_delimited(&mut buf)
.map_err(Error::EncodeMessage)?;
.map_err(Error::encode_message)?;

Ok(buf.to_vec())
}
Expand All @@ -51,7 +51,7 @@ impl SignBytes for BlockId {
let mut buf = Vec::new();
block_id
.encode_length_delimited(&mut buf)
.map_err(Error::EncodeMessage)?;
.map_err(Error::encode_message)?;

Ok(buf)
}
Expand All @@ -62,7 +62,7 @@ impl SignBytes for Vote {
let block_id = self
.block_id
.clone()
.ok_or(Error::CreateCanonical(String::from(
.ok_or(Error::create_canonical(String::from(
"missing vote.block id",
)))?;

Expand All @@ -76,7 +76,7 @@ impl SignBytes for Commit {
let block_id = self
.block_id
.clone()
.ok_or(Error::CreateCanonical(String::from(
.ok_or(Error::create_canonical(String::from(
"missing vote.block id",
)))?;

Expand Down Expand Up @@ -106,7 +106,7 @@ fn vote_sign_bytes(
let state_id = block_id.state_id.clone();
let block_id = block_id.sha256(ctx)?;

buf.put_i32_le(vote_type.into());
buf.put_i32_le(vote_type);
buf.put_i64_le(height);
buf.put_i64_le(round);

Expand Down

0 comments on commit c3a731a

Please sign in to comment.