From e3cfd8f86da5d69afefb0d4a9001c55d9ab0f57a Mon Sep 17 00:00:00 2001 From: ljedrz Date: Fri, 26 Nov 2021 09:06:47 +0100 Subject: [PATCH] perf: reduce the scope of the block requests lock in Ledger::update_block_requests Signed-off-by: ljedrz --- src/network/ledger.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/network/ledger.rs b/src/network/ledger.rs index c46c0c6896..e21606a41c 100644 --- a/src/network/ledger.rs +++ b/src/network/ledger.rs @@ -606,9 +606,6 @@ impl Ledger { return; } - // Acquire the lock for block requests. - let _block_requests_lock = self.block_requests_lock.lock().await; - // Retrieve the latest block height of this ledger. let latest_block_height = self.canon.latest_block_height(); @@ -655,6 +652,9 @@ impl Ledger { return; } + // Acquire the lock for block requests. + let _block_requests_lock = self.block_requests_lock.lock().await; + // Case 2 - Proceed to send block requests, as the peer is ahead of this ledger. if let (Some(peer_ip), Some(is_fork)) = (maximal_peer, maximal_peer_is_fork) { // Determine the common ancestor block height between this ledger and the peer.