Skip to content

Commit

Permalink
fix(node): remove blocks from queue earlier
Browse files Browse the repository at this point in the history
  • Loading branch information
rustaceanrob committed Sep 2, 2024
1 parent b65aa22 commit 87150e1
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions src/node/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<MainThreadMessage> {
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
Expand Down

0 comments on commit 87150e1

Please sign in to comment.