diff --git a/src/consensus/participant.rs b/src/consensus/participant.rs index 29178b8c7..40d489bc3 100644 --- a/src/consensus/participant.rs +++ b/src/consensus/participant.rs @@ -1,7 +1,7 @@ use std::{collections::BTreeMap, io}; use crate::{ - crypto::address::Address, + crypto::{address::Address, keypair::PublicKey}, impl_vec, net, util::serial::{Decodable, Encodable, SerialDecodable, SerialEncodable, VarInt}, Result, @@ -11,6 +11,8 @@ use crate::{ /// (`node_address`, `slot_joined`, `last_slot_voted`, `slot_quarantined`) #[derive(Debug, Clone, PartialEq, Eq, SerialEncodable, SerialDecodable)] pub struct Participant { + /// Node public key + pub public_key: PublicKey, /// Node wallet address pub address: Address, /// Slot node joined the network @@ -22,8 +24,8 @@ pub struct Participant { } impl Participant { - pub fn new(address: Address, joined: u64) -> Self { - Self { address, joined, voted: None, quarantined: None } + pub fn new(public_key: PublicKey, address: Address, joined: u64) -> Self { + Self { public_key, address, joined, voted: None, quarantined: None } } } diff --git a/src/consensus/state.rs b/src/consensus/state.rs index 6ea230994..df0a62611 100644 --- a/src/consensus/state.rs +++ b/src/consensus/state.rs @@ -866,7 +866,7 @@ impl ValidatorState { if self.consensus.participants.is_empty() { // If no nodes are active, node becomes a single node network. - let participant = Participant::new(self.address, self.current_slot()); + let participant = Participant::new(self.public, self.address, self.current_slot()); self.consensus.participants.insert(participant.address, participant); } diff --git a/src/consensus/task/proposal.rs b/src/consensus/task/proposal.rs index fdaba82d3..0ccfead4e 100644 --- a/src/consensus/task/proposal.rs +++ b/src/consensus/task/proposal.rs @@ -39,9 +39,10 @@ pub async fn proposal_task(consensus_p2p: P2pPtr, sync_p2p: P2pPtr, state: Valid }; // Node signals the network that it will start participating + let public = state.read().await.public; let address = state.read().await.address; let cur_slot = state.read().await.current_slot(); - let participant = Participant::new(address, cur_slot); + let participant = Participant::new(public, address, cur_slot); state.write().await.append_participant(participant.clone()); match consensus_p2p.broadcast(participant).await {