Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove usage of "unwrap" in the sct component #3008

Merged
merged 1 commit into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions crates/core/component/sct/src/component/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ pub trait StateReadExt: StateRead {
match self
.nonverifiable_get_raw(state_key::state_commitment_tree().as_bytes())
.await
.unwrap()
.expect("able to retrieve state commitment tree from nonverifiable storage")
{
Some(bytes) => bincode::deserialize(&bytes).unwrap(),
Some(bytes) => bincode::deserialize(&bytes).expect(
"able to deserialize stored state commitment tree from nonverifiable storage",
),
None => tct::Tree::new(),
}
}
Expand Down Expand Up @@ -135,7 +137,8 @@ trait StateWriteExt: StateWrite {
// If the cached tree is dirty, flush it to storage
if let Some(tree) = self.object_get::<tct::Tree>(state_key::cached_state_commitment_tree())
{
let bytes = bincode::serialize(&tree).unwrap();
let bytes = bincode::serialize(&tree)
.expect("able to serialize state commitment tree to bincode");
self.nonverifiable_put_raw(
state_key::state_commitment_tree().as_bytes().to_vec(),
bytes,
Expand Down
1 change: 1 addition & 0 deletions crates/core/component/sct/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![deny(clippy::unwrap_used)]
#![cfg_attr(docsrs, feature(doc_cfg))]

#[cfg_attr(docsrs, doc(cfg(feature = "component")))]
Expand Down
Loading