Skip to content

Commit 58cea5d

Browse files
committed
apollo_network: struct that holds the reason the peer is considered bad
1 parent ef0f911 commit 58cea5d

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

crates/apollo_consensus/src/manager.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ pub enum RunHeightRes {
188188

189189
type ProposalReceiverTuple<T> = (ProposalInit, mpsc::Receiver<T>);
190190

191-
// TODO(guyn): remove allow dead code once we use the duplicate vote report.
191+
// TODO(guyn): remove allow(dead_code) once we use this struct.
192192
#[allow(dead_code)]
193193
#[derive(Debug, Clone)]
194194
pub struct EquivocationVoteReport {

crates/apollo_network_types/src/network_types.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ impl OpaquePeerId {
2424
}
2525
}
2626

27-
// TODO(guyn): remove allow dead code once we use the duplicate vote report.
27+
// TODO(guyn): remove allow dead code once we use this struct.
2828
#[allow(dead_code)]
2929
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
3030
pub struct BadPeerReport {
3131
pub peer_id: OpaquePeerId,
32-
pub reason: String,
32+
pub reason: BadPeerReason,
3333
pub penalty_card: PenaltyCard,
3434
}
3535

@@ -42,3 +42,12 @@ pub enum PenaltyCard {
4242
/// Possibly sent malicious data on accident, will be considered malicious on repeat offenses.
4343
Yellow,
4444
}
45+
46+
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
47+
pub enum BadPeerReason {
48+
/// Protobuf conversion has failed.
49+
ConversionError(String),
50+
/// Duplicate and conflicting vote was received from the same peer for the same height, round,
51+
/// and phase.
52+
EquivocationVote(String),
53+
}

0 commit comments

Comments
 (0)