Skip to content

Commit

Permalink
rb_handler fix1
Browse files Browse the repository at this point in the history
  • Loading branch information
ibalajiarun committed Feb 6, 2024
1 parent 0cbe0ef commit 373112d
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions consensus/src/dag/rb_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,15 @@ impl RpcHandler for NodeBroadcastHandler {
NodeBroadcastHandleError::VoteRefused
);

let key = (node.round(), *node.author());
ensure!(
self.votes_fine_grained_lock.insert(key),
"concurrent insertion"
);
defer!({
assert_some!(self.votes_fine_grained_lock.remove(&key));
});

let node = self.validate(node)?;
observe_node(node.timestamp(), NodeStage::NodeReceived);
debug!(LogSchema::new(LogEvent::ReceiveNode)
Expand All @@ -221,17 +230,6 @@ impl RpcHandler for NodeBroadcastHandler {
return Ok(ack.clone());
}

ensure!(
self.votes_fine_grained_lock
.insert((node.round(), *node.author())),
"concurrent insertion"
);
defer!({
assert_some!(self
.votes_fine_grained_lock
.remove(&(node.round(), *node.author())));
});

let signature = node.sign_vote(&self.signer)?;
let vote = Vote::new(node.metadata().clone(), signature);
self.storage.save_vote(&node.id(), &vote)?;
Expand Down

0 comments on commit 373112d

Please sign in to comment.