summaryrefslogtreecommitdiffstats
path: root/src/transport/mycelium/mod.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-10-26 19:29:59 +0100
committertv <tv@krebsco.de>2026-10-26 19:29:59 +0100
commit4bbadf6fdc4733b4c3c5eeb575508b2f9334ebdb (patch)
treee79ad53ac99932c94b5bc581b382c919cfc9bb17 /src/transport/mycelium/mod.rs
parent9a165fd06a1b52bb943a84f26adf8dec72056143 (diff)
keepalive sends head samples alongside digest
When there are more than 32 heads that can be send in a single keepalive message, the digest is accompanied by 32 heads, a different window each time, so after a few keepalives every head has been listed.
Diffstat (limited to 'src/transport/mycelium/mod.rs')
-rw-r--r--src/transport/mycelium/mod.rs10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/transport/mycelium/mod.rs b/src/transport/mycelium/mod.rs
index 585b5ee..495f75e 100644
--- a/src/transport/mycelium/mod.rs
+++ b/src/transport/mycelium/mod.rs
@@ -529,9 +529,10 @@ mod tests {
#[test]
fn largest_keepalive_fits_in_one_chunk() {
+ // A digest with a full sample: the most a keepalive carries.
let keepalive = Keepalive {
- heads: HeadsSummary::Heads(
- (0..MAX_LISTED_HEADS as u8)
+ heads: HeadsSummary::of(
+ (0..=MAX_LISTED_HEADS as u8)
.map(|n| ChangeHash([n; 32]))
.collect(),
),
@@ -624,7 +625,10 @@ mod tests {
fn listed_heads_equal_their_digest() {
let heads: Vec<_> = (0..3u8).map(|n| ChangeHash([n; 32])).collect();
let listed = HeadsSummary::of(heads.clone());
- let digest = HeadsSummary::Digest(listed.digest());
+ let digest = HeadsSummary::Digest {
+ digest: listed.digest(),
+ sample: Vec::new(),
+ };
assert_eq!(listed, digest);
assert_ne!(listed, HeadsSummary::of(heads[..2].to_vec()));
}