aboutsummaryrefslogtreecommitdiffstats
path: root/src/transport/mycelium
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
commitc5cd59e632e9ff22aa1f6b5ca9a1eb3ec935a312 (patch)
tree11a7eb5c70587d97734960f7c8595bd244c79541 /src/transport/mycelium
parentae5d7419cf0f81dda89547e58e44153c57b60115 (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')
-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()));
}