From 54f0d332a4942e18425d6e13b267916bac709049 Mon Sep 17 00:00:00 2001 From: SW van Heerden Date: Thu, 5 Dec 2024 15:04:53 +0200 Subject: [PATCH] fix: panic (#209) Description --- fixx panic --- 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 c521c07..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; + let index = i_have_blocks.len().saturating_sub(counter).saturating_sub(1); i_have_blocks[index] = (height, block.hash); counter += 1; }