Skip to content

Commit

Permalink
Ask for headers only once (mit-dci#40)
Browse files Browse the repository at this point in the history
In some cases, we might ask for headers twice, downloading duplicated
headers during ibd. This commit fixes it
  • Loading branch information
Davidson-Souza authored May 3, 2023
1 parent f518a30 commit 2f6f7e5
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/blockchain/p2p_blockchain/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,16 +445,20 @@ impl UtreexoNode {

if version.services.has(ServiceFlags::NODE_UTREEXO) {
if let NodeState::WaitingPeer = self.state {
try_and_log!(
self.send_to_random_peer(
NodeRequest::GetHeaders(
self.chain.get_block_locator().expect("Can get locators"),
),
ServiceFlags::NONE
)
.await
);
self.state = NodeState::DownloadHeaders;
if !self.inflight.contains_key(&InflightRequests::Headers) {
try_and_log!(
self.send_to_random_peer(
NodeRequest::GetHeaders(
self.chain
.get_block_locator()
.expect("Can get locators"),
),
ServiceFlags::NONE
)
.await
);
self.state = NodeState::DownloadHeaders;
}
}
}
}
Expand Down

0 comments on commit 2f6f7e5

Please sign in to comment.