diff --git a/CHANGELOG.md b/CHANGELOG.md index f2ca916..38a46f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add range checks to MTU (between 1296 and 8192) - Add network version to handshake messages - Add Ray-ID to MessageInfo for message tracking +- Add warning when discarding incomplete messages ### Fixed diff --git a/src/transport/encoding/raptorq/decoder.rs b/src/transport/encoding/raptorq/decoder.rs index a394489..68c7d6d 100644 --- a/src/transport/encoding/raptorq/decoder.rs +++ b/src/transport/encoding/raptorq/decoder.rs @@ -81,6 +81,10 @@ enum CacheStatus { } impl CacheStatus { + fn receiving(&self) -> bool { + matches!(&self, CacheStatus::Receiving(..)) + } + fn expired(&self) -> bool { let expire_on = match self { CacheStatus::Receiving(info, _) => &info.expire_on, @@ -223,7 +227,16 @@ impl Decoder for RaptorQDecoder { }; // Every X time, prune dupemap cache if self.last_pruned.elapsed() > self.conf.cache_prune_every { - self.cache.retain(|_, status| !status.expired()); + self.cache.retain(|ray_id, status| { + let keep = !status.expired(); + if !keep && status.receiving() { + warn!( + event = "dupemap discard", + ray = hex::encode(ray_id) + ); + }; + keep + }); self.last_pruned = Instant::now(); } Ok(decoded)