Skip to content

Commit

Permalink
perf: lock the known transmissions when checking the batch header
Browse files Browse the repository at this point in the history
Signed-off-by: ljedrz <[email protected]>
  • Loading branch information
ljedrz committed Oct 10, 2023
1 parent 897e19e commit 98eef8e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion node/narwhal/src/helpers/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,10 +337,12 @@ impl<N: Network> Storage<N> {

// Initialize a list for the missing transmissions from storage.
let mut missing_transmissions = HashMap::new();
// Lock the existing transmissions.
let known_transmissions = self.transmissions.read();
// Ensure the declared transmission IDs are all present in storage or the given transmissions map.
for transmission_id in batch_header.transmission_ids() {
// If the transmission ID does not exist, ensure it was provided by the caller.
if !self.transmissions.read().contains_key(transmission_id) {
if !known_transmissions.contains_key(transmission_id) {
// Retrieve the transmission.
let Some(transmission) = transmissions.remove(transmission_id) else {
bail!("Failed to provide a transmission for round {round} {gc_log}");
Expand Down

0 comments on commit 98eef8e

Please sign in to comment.