mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-04-28 03:00:18 -04:00
consensus: added node public key to Participant struct
This commit is contained in:
@@ -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 }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user