Skip to content

Commit

Permalink
perf: reduce the scope of the block requests lock in Ledger::update_b…
Browse files Browse the repository at this point in the history
…lock_requests

Signed-off-by: ljedrz <[email protected]>
  • Loading branch information
ljedrz committed Nov 26, 2021
1 parent 8e352fc commit e3cfd8f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/network/ledger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -606,9 +606,6 @@ impl<N: Network, E: Environment> Ledger<N, E> {
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();

Expand Down Expand Up @@ -655,6 +652,9 @@ impl<N: Network, E: Environment> Ledger<N, E> {
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.
Expand Down

0 comments on commit e3cfd8f

Please sign in to comment.