diff options
| author | tv <tv@krebsco.de> | 2026-10-24 20:09:15 +0200 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-10-24 20:09:15 +0200 |
| commit | 02c90641fbb149392b3d20ab874c3c0e8595f42a (patch) | |
| tree | 517c7d0b60618b179b4b98a5e1da6e1630bd707a /src/remake/mod.rs | |
| parent | c8c78b48eabab7d24b90daa26a5d1e4d888bd092 (diff) | |
follow and download from ready members only
Diffstat (limited to 'src/remake/mod.rs')
| -rw-r--r-- | src/remake/mod.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/remake/mod.rs b/src/remake/mod.rs index 2dd646b..aa1d583 100644 --- a/src/remake/mod.rs +++ b/src/remake/mod.rs @@ -141,10 +141,30 @@ pub(crate) struct PeerSummary { pub(crate) id: String, /// Not dormant. pub(crate) active: bool, + /// Completed the handshake and belongs to our swarm. A peer that merely sent us + /// something (a node of another swarm on the same network, a stranger before + /// admission) is not one, and nothing it advertises is followed. + pub(crate) member: bool, + /// What it last said about being ready; None before it said anything. + pub(crate) ready: Option<bool>, /// The epoch the peer last advertised. pub(crate) epoch: Option<Epoch>, } +impl PeerSummary { + /// A peer whose epoch can be followed and downloaded from: an active member that + /// holds the document it advertises. A rejoining peer advertises its target epoch + /// with an empty document and `ready: false`. + pub(crate) fn serves_epoch(&self, epoch: Epoch) -> bool { + self.serves() && self.epoch == Some(epoch) + } + + /// An active, ready member. + pub(crate) fn serves(&self) -> bool { + self.active && self.member && self.ready == Some(true) + } +} + /// Largest remake request (bytes). The proposal carries the new document to every /// node in one sync message, which Mycelium must deliver within its deadline, so /// documents near this size are already a stretch. |
