Skip to content

Commit

Permalink
Merge pull request #234 from bitfinity-network/fix_wrong_cast
Browse files Browse the repository at this point in the history
Fix wrong cast that could lead to a panic
  • Loading branch information
ufoscout authored Nov 12, 2024
2 parents 79943c2 + 43d06c3 commit f63aacf
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ic-stable-structures/src/structure/cache/multimap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ where
Some(res)
}

fn len(&self) -> usize {
fn len(&self) -> u64 {
self.inner.len()
}

Expand Down
2 changes: 1 addition & 1 deletion ic-stable-structures/src/structure/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ pub trait MultimapStructure<K1, K2, V> {
fn pop_last(&mut self) -> Option<((K1, K2), V)>;

/// Items count.
fn len(&self) -> usize;
fn len(&self) -> u64;

/// Is map empty.
fn is_empty(&self) -> bool;
Expand Down
4 changes: 2 additions & 2 deletions ic-stable-structures/src/structure/stable_storage/multimap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ where
self.0.pop_last()
}

fn len(&self) -> usize {
self.0.len() as usize
fn len(&self) -> u64 {
self.0.len()
}

fn is_empty(&self) -> bool {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ impl Service {

pub fn insert_tx_to_multimap(transaction: BoundedTransaction) -> u64 {
TX_MULTIMAP.with(|storage| {
let new_key = storage.borrow().len() as u64;
let new_key = storage.borrow().len();
storage
.borrow_mut()
.insert(&new_key, &(new_key + 1), transaction);
Expand Down

0 comments on commit f63aacf

Please sign in to comment.