pub struct Peer {
pub id: Id,
pub verification_key_bytes: VerificationKeyBytes,
pub pq_commitment_bytes: PQCommitmentBytes,
pub pow_initial: PeerPow,
pub pow_current_day: PeerPow,
pub pow_current_month: PeerPow,
pub version: String,
pub address: String,
pub timestamp: TimeMillis,
pub signature: Signature,
}Expand description
A single node’s self-signed identity record, gossiped through the Kademlia DHT.
Peer is the unit of peer discovery. Each server publishes one: its Id, its Ed25519
verification key, its post-quantum commitment, its current network address, its build
version, and three PeerPow tokens — one fixed “initial” PoW that was produced at
startup and never changes (so it acts as a long-term identity credential), plus rolling
“best seen this day” and “best seen this month” PoWs that keep the record fresh and let
other peers weight trust by recent work. The whole thing is covered by a signature
so tampering is detectable.
Other peers store, forward, and compare Peer records to decide who to talk to, which
is why the PoW fields have time decay built in (pow_decayed_day, pow_decayed_month)
— stale records age out naturally.
Fields§
§id: Id§verification_key_bytes: VerificationKeyBytes§pq_commitment_bytes: PQCommitmentBytes§pow_initial: PeerPow§pow_current_day: PeerPow§pow_current_month: PeerPow§version: String§address: String§timestamp: TimeMillis§signature: SignatureImplementations§
Source§impl Peer
impl Peer
pub fn zero() -> Peer
Sourcepub fn score(&self, time_millis: TimeMillis) -> f64
pub fn score(&self, time_millis: TimeMillis) -> f64
How much we value this peer right now: rewards being currently active (decayed daily pow) while also favouring peers that have been active for a while (decayed monthly pow). Shared by the server’s Kademlia and the client’s PeerTracker eviction so both sides rank peers identically.
pub fn signature_hash_generate(&self) -> Result<Hash>
pub fn sign( &mut self, time_provider: &dyn TimeProvider, signature_key: &SignatureKey, ) -> Result<()>
pub fn verify(&self) -> Result<()>
Sourcepub fn verify_timestamps(&self, current_time_millis: TimeMillis) -> Result<()>
pub fn verify_timestamps(&self, current_time_millis: TimeMillis) -> Result<()>
Rejects records whose timestamps are further into our future than honest clock drift allows
(see config::PEER_MAX_FUTURE_TIMESTAMP_MILLIS). Old timestamps are fine — PoW decay handles them.
Separate from Self::verify because it needs the current time and only matters where peers are scored.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Peer
impl<'de> Deserialize<'de> for Peer
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl StructuralPartialEq for Peer
Auto Trait Implementations§
impl Freeze for Peer
impl RefUnwindSafe for Peer
impl Send for Peer
impl Sync for Peer
impl Unpin for Peer
impl UnsafeUnpin for Peer
impl UnwindSafe for Peer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more