From 363448cd012600e944a6cf9fff2aa79120117461 Mon Sep 17 00:00:00 2001 From: Gregory Terzian <2792687+gterzian@users.noreply.github.com> Date: Fri, 10 May 2019 20:15:36 +0800 Subject: [PATCH] don't acquire the lock unless, and only hold it for as long as, necessary. (#2530) --- .../core/finality-grandpa/src/communication/gossip.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/substrate/core/finality-grandpa/src/communication/gossip.rs b/substrate/core/finality-grandpa/src/communication/gossip.rs index 93511b759d..62bfe8a657 100644 --- a/substrate/core/finality-grandpa/src/communication/gossip.rs +++ b/substrate/core/finality-grandpa/src/communication/gossip.rs @@ -623,13 +623,12 @@ impl GossipValidator { { let mut broadcast_topics = Vec::new(); let action = { - let mut inner = self.inner.write(); match GossipMessage::::decode(&mut data) { Some(GossipMessage::VoteOrPrecommit(ref message)) - => inner.validate_round_message(who, message), - Some(GossipMessage::Commit(ref message)) => inner.validate_commit_message(who, message), + => self.inner.write().validate_round_message(who, message), + Some(GossipMessage::Commit(ref message)) => self.inner.write().validate_commit_message(who, message), Some(GossipMessage::Neighbor(update)) => { - let (topics, action) = inner.import_neighbor_message( + let (topics, action) = self.inner.write().import_neighbor_message( who, update.into_neighbor_packet(), );