From cc72c969fe6e713ef8a95041b3884d2ba9aeb505 Mon Sep 17 00:00:00 2001 From: Brian Cho Date: Fri, 9 Dec 2022 10:41:53 -0800 Subject: [PATCH] Add quorum store sender messages to QuorumStoreSender trait --- consensus/src/network.rs | 34 +++++++++++++++--------------- consensus/src/network_interface.rs | 2 +- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/consensus/src/network.rs b/consensus/src/network.rs index e402b7d2754bb..ff1a65bb18e7d 100644 --- a/consensus/src/network.rs +++ b/consensus/src/network.rs @@ -66,10 +66,14 @@ pub struct NetworkReceivers { } #[async_trait::async_trait] -pub trait QuorumStoreSender { +pub(crate) trait QuorumStoreSender { async fn send_batch(&self, batch: Batch, recipients: Vec); async fn send_signed_digest(&self, signed_digest: SignedDigest, recipients: Vec); + + async fn broadcast_fragment(&mut self, fragment: Fragment); + + async fn broadcast_proof_of_store(&mut self, proof_of_store: ProofOfStore); } /// Implements the actual networking support for all consensus messaging. @@ -244,22 +248,6 @@ impl NetworkSender { self.send(msg, vec![recipient]).await } - // TODO: remove allow(dead_code) when quorum store implementation is added - #[allow(dead_code)] - pub async fn broadcast_fragment(&mut self, fragment: Fragment) { - fail_point!("consensus::send::broadcast_fragment", |_| ()); - let msg = ConsensusMsg::FragmentMsg(Box::new(fragment)); - self.broadcast_without_self(msg).await - } - - // TODO: remove allow(dead_code) when quorum store implementation is added - #[allow(dead_code)] - pub async fn broadcast_proof_of_store(&mut self, proof_of_store: ProofOfStore) { - fail_point!("consensus::send::proof_of_store", |_| ()); - let msg = ConsensusMsg::ProofOfStoreMsg(Box::new(proof_of_store)); - self.broadcast_without_self(msg).await - } - /// Sends the vote to the chosen recipients (typically that would be the recipients that /// we believe could serve as proposers in the next round). The recipients on the receiving /// end are going to be notified about a new vote in the vote queue. @@ -320,6 +308,18 @@ impl QuorumStoreSender for NetworkSender { let msg = ConsensusMsg::SignedDigestMsg(Box::new(signed_digest)); self.send(msg, recipients).await } + + async fn broadcast_fragment(&mut self, fragment: Fragment) { + fail_point!("consensus::send::broadcast_fragment", |_| ()); + let msg = ConsensusMsg::FragmentMsg(Box::new(fragment)); + self.broadcast_without_self(msg).await + } + + async fn broadcast_proof_of_store(&mut self, proof_of_store: ProofOfStore) { + fail_point!("consensus::send::proof_of_store", |_| ()); + let msg = ConsensusMsg::ProofOfStoreMsg(Box::new(proof_of_store)); + self.broadcast_without_self(msg).await + } } pub struct NetworkTask { diff --git a/consensus/src/network_interface.rs b/consensus/src/network_interface.rs index 8482c39523111..36172ef3353f7 100644 --- a/consensus/src/network_interface.rs +++ b/consensus/src/network_interface.rs @@ -73,7 +73,7 @@ pub enum ConsensusMsg { /// Quorum Store: Send a signed batch digest. This is a vote for the batch and a promise that /// the batch of transactions was received and will be persisted until batch expiration. SignedDigestMsg(Box), - /// Quorum Store: Broadcast a completed proof of store (a digest that received 2f+1 votes). + /// Quorum Store: Broadcast a certified proof of store (a digest that received 2f+1 votes). ProofOfStoreMsg(Box), }