From 601b452c7cf59405be75be4923e86b498e118aea Mon Sep 17 00:00:00 2001 From: ii-cruz Date: Mon, 25 Nov 2024 01:25:48 -0600 Subject: [PATCH] Compile fix --- dht/src/lib.rs | 2 +- network-libp2p/src/dht.rs | 4 +++- network-libp2p/src/discovery/peer_contacts.rs | 12 ++++-------- network-libp2p/tests/network.rs | 2 +- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/dht/src/lib.rs b/dht/src/lib.rs index d7198d16cc..5ffcc2185b 100644 --- a/dht/src/lib.rs +++ b/dht/src/lib.rs @@ -136,7 +136,7 @@ impl DhtVerifier for Verifier { } self.verify_validator_record(&validator_record) - .map_err(DhtVerifierError::ValidatorInfoError) + .map_err(|_| DhtVerifierError::ValidatorInfoError) .and_then(|_| { Ok(DhtRecord::Validator( validator_record.record.peer_id, diff --git a/network-libp2p/src/dht.rs b/network-libp2p/src/dht.rs index a0fbe47307..a6590193f6 100644 --- a/network-libp2p/src/dht.rs +++ b/network-libp2p/src/dht.rs @@ -5,7 +5,7 @@ use nimiq_serde::DeserializeError; use nimiq_validator_network::validator_record::ValidatorRecord; pub use crate::network_types::DhtRecord; -use crate::{discovery::peer_contacts::ValidatorInfoError, Network}; +use crate::Network; #[derive(Debug)] pub enum DhtVerifierError { @@ -22,6 +22,8 @@ pub enum DhtVerifierError { ), StateIncomplete, InvalidSignature, + ValidatorInfoError, + MissingPublisher, } pub trait Verifier: Send + Sync { diff --git a/network-libp2p/src/discovery/peer_contacts.rs b/network-libp2p/src/discovery/peer_contacts.rs index 0d2467cbd6..52043d0f82 100644 --- a/network-libp2p/src/discovery/peer_contacts.rs +++ b/network-libp2p/src/discovery/peer_contacts.rs @@ -129,16 +129,13 @@ pub struct PeerContact { #[serde(with = "self::serde_public_key")] pub public_key: PublicKey, - /// Optional validator info in case the node is a validator. - pub validator_info: Option, - - /// Services supported by this peer. - pub services: Services, - /// Optional [ValidatorInfo] in case the node represented by this contact is /// running a validator. validator_info: Option, + /// Services supported by this peer. + pub services: Services, + /// Timestamp when this peer contact was created in *seconds* since unix epoch. timestamp: u64, } @@ -165,7 +162,6 @@ impl PeerContact { public_key, validator_info: None, services, - validator_info: None, timestamp, }) } @@ -291,7 +287,7 @@ impl SignedPeerContact { &self, #[cfg(feature = "kad")] verifier: Arc, ) -> Result<(), PeerContactError> { - // The record signature must be verifid first. + // The record signature must be verified first. if !self .signature .tagged_verify(&self.inner, &self.inner.public_key) diff --git a/network-libp2p/tests/network.rs b/network-libp2p/tests/network.rs index b097a7485e..d49cd7b27a 100644 --- a/network-libp2p/tests/network.rs +++ b/network-libp2p/tests/network.rs @@ -259,7 +259,7 @@ impl dht::Verifier for Verifier { record.clone(), ) }) - .map_err(dht::DhtVerifierError::ValidatorInfoError) + .map_err(|_| dht::DhtVerifierError::ValidatorInfoError) } }