Skip to content

Commit

Permalink
runtime/consensus/roothash: update error type in round results
Browse files Browse the repository at this point in the history
  • Loading branch information
ptrus committed Nov 21, 2023
1 parent adf3314 commit 9330fa9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Empty file added .changelog/5460.trivial.md
Empty file.
8 changes: 4 additions & 4 deletions runtime/src/consensus/state/roothash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,21 @@ impl<'a, T: ImmutableMKVS> ImmutableState<'a, T> {
}

// Returns the state and I/O roots for the given runtime and round.
pub fn round_roots(&self, id: Namespace, round: u64) -> Result<Option<RoundRoots>, Error> {
pub fn round_roots(&self, id: Namespace, round: u64) -> Result<Option<RoundRoots>, StateError> {
match self
.mkvs
.get(&PastRootsKeyFmt((Hash::digest_bytes(id.as_ref()), round)).encode())
{
Ok(Some(b)) => {
cbor::from_slice(&b).map_err(|err| StateError::Unavailable(anyhow!(err)).into())
cbor::from_slice(&b).map_err(|err| StateError::Unavailable(anyhow!(err)))
}
Ok(None) => Ok(None),
Err(err) => Err(StateError::Unavailable(anyhow!(err)).into()),
Err(err) => Err(StateError::Unavailable(anyhow!(err))),
}
}

// Returns all past round roots for the given runtime.
pub fn past_round_roots(&self, id: Namespace) -> Result<BTreeMap<u64, RoundRoots>, Error> {
pub fn past_round_roots(&self, id: Namespace) -> Result<BTreeMap<u64, RoundRoots>, StateError> {
let h = Hash::digest_bytes(id.as_ref());
let mut it = self.mkvs.iter();
it.seek(&PastRootsKeyFmt((h, Default::default())).encode_partial(1));
Expand Down

0 comments on commit 9330fa9

Please sign in to comment.