Skip to content

Commit

Permalink
Add quorum store sender messages to QuorumStoreSender trait
Browse files Browse the repository at this point in the history
  • Loading branch information
bchocho committed Dec 9, 2022
1 parent 8e27878 commit cc72c96
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
34 changes: 17 additions & 17 deletions consensus/src/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Author>);

async fn send_signed_digest(&self, signed_digest: SignedDigest, recipients: Vec<Author>);

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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion consensus/src/network_interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<SignedDigest>),
/// 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<ProofOfStore>),
}

Expand Down

0 comments on commit cc72c96

Please sign in to comment.