diff --git a/src/sharechain/in_memory.rs b/src/sharechain/in_memory.rs index 26d64ea..2415d81 100644 --- a/src/sharechain/in_memory.rs +++ b/src/sharechain/in_memory.rs @@ -782,7 +782,7 @@ impl ShareChain for InMemoryShareChain { }; if let Some(level) = p2_chain_read_lock.level_at_height(height) { if let Some(block) = level.block_in_main_chain() { - let index = i_have_blocks.len() - counter - 1; + let index = i_have_blocks.len().saturating_sub(counter).saturating_sub(1); i_have_blocks[index] = (height, block.hash); counter += 1; }