From 87150e1f7b4bd63689a54a05948beca618679a11 Mon Sep 17 00:00:00 2001 From: Rob N Date: Mon, 2 Sep 2024 08:49:01 -1000 Subject: [PATCH] fix(node): remove blocks from queue earlier --- src/node/node.rs | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/node/node.rs b/src/node/node.rs index cd373f1..9af8c15 100644 --- a/src/node/node.rs +++ b/src/node/node.rs @@ -672,25 +672,25 @@ impl Node { // The block queue holds all the block hashes we may be interested in async fn pop_block_queue(&mut self) -> Option { let state = self.state.read().await; - let mut chain = self.chain.lock().await; - // Do we actually need to wait for the headers to sync? - match *state { - NodeState::FiltersSynced => { - let next_block_hash = chain.next_block(); - match next_block_hash { - Some(block_hash) => { - self.dialog - .send_dialog(format!("Next block in queue: {}", block_hash)) - .await; - Some(MainThreadMessage::GetBlock(GetBlockConfig { - locator: block_hash, - })) - } - None => None, + if matches!( + *state, + NodeState::FilterHeadersSynced | NodeState::FiltersSynced + ) { + let mut chain = self.chain.lock().await; + let next_block_hash = chain.next_block(); + return match next_block_hash { + Some(block_hash) => { + self.dialog + .send_dialog(format!("Next block in queue: {}", block_hash)) + .await; + Some(MainThreadMessage::GetBlock(GetBlockConfig { + locator: block_hash, + })) } - } - _ => None, + None => None, + }; } + None } // If new inventory came in, we need to download the headers and update the node state