pub struct DhtStateSnapshot {
pub nodes: Vec<DhtNodeInfo>,
pub token_secret: [u8; 20],
pub last_bootstrap_epoch_secs: Option<u64>,
pub total_nodes: usize,
}Expand description
Snapshot of DHT (Distributed Hash Table) routing state for persistence.
Captures the current state of DHT nodes, token secret, and bootstrap timing to allow quick resumption without full bootstrap on restart.
§Serialization
This struct implements Serialize/Deserialize for JSON persistence alongside
session data. Use to_json_string() and from_json_string() for conversion.
Fields§
§nodes: Vec<DhtNodeInfo>Known DHT nodes in the routing table
token_secret: [u8; 20]Current token secret used for DHT get_peers requests (20 bytes)
last_bootstrap_epoch_secs: Option<u64>Unix epoch timestamp of last successful bootstrap, if any
total_nodes: usizeTotal number of nodes in the snapshot (convenience field)
Implementations§
Source§impl DhtStateSnapshot
impl DhtStateSnapshot
Sourcepub fn empty() -> Self
pub fn empty() -> Self
Create an empty snapshot (for when DHT is unavailable or not initialized).
Returns a snapshot with no nodes and zeroed token secret, suitable as a default or placeholder value.
Sourcepub fn new(
nodes: Vec<DhtNodeInfo>,
token_secret: [u8; 20],
last_bootstrap_epoch_secs: Option<u64>,
) -> Self
pub fn new( nodes: Vec<DhtNodeInfo>, token_secret: [u8; 20], last_bootstrap_epoch_secs: Option<u64>, ) -> Self
Create a snapshot from node data with automatic total_nodes calculation.
§Arguments
nodes- Vector of known DHT nodestoken_secret- Current 20-byte token secretlast_bootstrap- Optional timestamp of last bootstrap
Trait Implementations§
Source§impl Clone for DhtStateSnapshot
impl Clone for DhtStateSnapshot
Source§fn clone(&self) -> DhtStateSnapshot
fn clone(&self) -> DhtStateSnapshot
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more