pub struct CloseGroupCache {
pub peers: Vec<CachedCloseGroupPeer>,
pub saved_at_epoch_secs: u64,
}Expand description
Persisted close group snapshot with trust scores.
Saved periodically during normal operation, after initial bootstrap, and on shutdown. Loaded on startup to reconnect to the same trusted close group peers, preserving close group consistency across restarts. Stale snapshots are skipped as Priority-0 bootstrap material according to the node’s configured maximum cache age.
Fields§
§peers: Vec<CachedCloseGroupPeer>Close group peers with their trust scores
saved_at_epoch_secs: u64When this snapshot was saved (seconds since UNIX epoch)
Implementations§
Source§impl CloseGroupCache
impl CloseGroupCache
Sourcepub fn is_stale(&self, now_epoch_secs: u64, max_age: Option<Duration>) -> bool
pub fn is_stale(&self, now_epoch_secs: u64, max_age: Option<Duration>) -> bool
Return whether this snapshot is older than max_age relative to
now_epoch_secs.
None disables the maximum-age check, but timestamps materially in the
future are always rejected. Small offsets are tolerated for clock skew.
Sourcepub async fn save_to_dir(&self, dir: &Path) -> Result<()>
pub async fn save_to_dir(&self, dir: &Path) -> Result<()>
Save the cache to {dir}/close_group_cache.json.
Uses tempfile::NamedTempFile::persist for atomicity: the temp file
has a unique name (safe under concurrent saves) and persist is an
atomic rename on Unix and a replace-then-rename on Windows.
Sourcepub async fn load_from_dir(dir: &Path) -> Result<Option<Self>>
pub async fn load_from_dir(dir: &Path) -> Result<Option<Self>>
Load the cache from {dir}/close_group_cache.json.
Returns None if the file doesn’t exist (fresh start).
Trait Implementations§
Source§impl Clone for CloseGroupCache
impl Clone for CloseGroupCache
Source§fn clone(&self) -> CloseGroupCache
fn clone(&self) -> CloseGroupCache
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more