From b9f8e8f084eb0d3fbfc83833db3517d15aca50c8 Mon Sep 17 00:00:00 2001 From: stringhandler Date: Wed, 4 Dec 2024 13:22:44 +0200 Subject: [PATCH 1/2] fix: more logs to request sync logic --- src/sharechain/in_memory.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/sharechain/in_memory.rs b/src/sharechain/in_memory.rs index 04b0ba5..603756a 100644 --- a/src/sharechain/in_memory.rs +++ b/src/sharechain/in_memory.rs @@ -700,16 +700,16 @@ impl ShareChain for InMemoryShareChain { // Go back and find the split in the chain for their_block in their_blocks { if let Some(level) = p2_chain_read.level_at_height(their_block.0) { - if let Some(block) = level.blocks.get(&their_block.1) { - // Only split if the block is in the main chain - if level.chain_block == block.hash { - split_height2 = block.height.saturating_add(1); - break; - } + // Only split if the block is in the main chain + if level.chain_block == their_block.1 { + split_height2 = their_block.0.saturating_add(1); + break; } } } + info!(target: LOG_TARGET, "[{:?}] Requesting sync, split_height1 {} splitheight2 {} last block {}", self.pow_algo, split_height, split_height2, last_block_received.as_ref().map(|(h, f)| h.to_string()).unwrap_or("None".to_string())); + let blocks = self.all_blocks_with_lock(&p2_chain_read, Some(cmp::max(split_height, split_height2)), limit, true)?; let tip_level = p2_chain_read From d9409472f3e75bdb32c2aba312be63d5079062bf Mon Sep 17 00:00:00 2001 From: stringhandler Date: Wed, 4 Dec 2024 13:32:19 +0200 Subject: [PATCH 2/2] fix clippy --- 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 603756a..1c8b6b1 100644 --- a/src/sharechain/in_memory.rs +++ b/src/sharechain/in_memory.rs @@ -708,7 +708,7 @@ impl ShareChain for InMemoryShareChain { } } - info!(target: LOG_TARGET, "[{:?}] Requesting sync, split_height1 {} splitheight2 {} last block {}", self.pow_algo, split_height, split_height2, last_block_received.as_ref().map(|(h, f)| h.to_string()).unwrap_or("None".to_string())); + info!(target: LOG_TARGET, "[{:?}] Requesting sync, split_height1 {} splitheight2 {} last block {}", self.pow_algo, split_height, split_height2, last_block_received.as_ref().map(|(h, _)| h.to_string()).unwrap_or("None".to_string())); let blocks = self.all_blocks_with_lock(&p2_chain_read, Some(cmp::max(split_height, split_height2)), limit, true)?;