Skip to content

Commit da70d20

Browse files
committed
apollo_consensus: add helper function to report peer
1 parent bcdf977 commit da70d20

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

crates/apollo_consensus/src/manager.rs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,21 @@ impl<ContextT: ConsensusContext> MultiHeightManager<ContextT> {
783783
}
784784
}
785785

786+
fn report_peer(
787+
&self,
788+
broadcast_channels: &mut BroadcastVoteChannel,
789+
metadata: &BroadcastedMessageMetadata,
790+
) {
791+
if broadcast_channels
792+
.broadcast_topic_client
793+
.report_peer(metadata.clone())
794+
.now_or_never()
795+
.is_none()
796+
{
797+
error!("Unable to send report_peer. {:?}", metadata);
798+
}
799+
}
800+
786801
async fn handle_proposal_known_block_info(
787802
&mut self,
788803
context: &mut ContextT,
@@ -822,14 +837,7 @@ impl<ContextT: ConsensusContext> MultiHeightManager<ContextT> {
822837
}
823838
(Err(e), metadata) => {
824839
// Failed to parse consensus message. Report the peer and drop the vote.
825-
if broadcast_channels
826-
.broadcast_topic_client
827-
.report_peer(metadata.clone())
828-
.now_or_never()
829-
.is_none()
830-
{
831-
error!("Unable to send report_peer. {:?}", metadata)
832-
}
840+
self.report_peer(broadcast_channels, &metadata);
833841
warn!(
834842
"Failed to parse incoming consensus vote, dropping vote. Error: {e}. Vote \
835843
metadata: {metadata:?}"

0 commit comments

Comments
 (0)