Skip to content

Commit

Permalink
Remove unwraps
Browse files Browse the repository at this point in the history
  • Loading branch information
tmpolaczyk committed Jan 15, 2024
1 parent 33bb876 commit 6e32705
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pallets/relay-storage-roots/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,10 @@ pub mod pallet {
let mut keys: VecDeque<_> = <RelayStorageRootKeys<T>>::get().into_inner().into();
keys.push_back(relay_state.number);
// Delete the oldest stored root if the total number is greater than MaxStorageRoots
if u32::try_from(keys.len()).unwrap() > T::MaxStorageRoots::get() {
let first_key = keys.pop_front().unwrap();
<RelayStorageRoot<T>>::remove(first_key);
if u32::try_from(keys.len()).unwrap_or(u32::MAX) > T::MaxStorageRoots::get() {
if let Some(first_key) = keys.pop_front() {
<RelayStorageRoot<T>>::remove(first_key);
}
}

let keys = BoundedVec::truncate_from(keys.into());
Expand Down

0 comments on commit 6e32705

Please sign in to comment.