From f2a83a8efcdd2430a3349fdea964122f4da9a0b6 Mon Sep 17 00:00:00 2001 From: SW van Heerden Date: Thu, 5 Dec 2024 14:40:11 +0200 Subject: [PATCH] change to saturating sub --- src/sharechain/in_memory.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; }