Skip to content

Commit

Permalink
Merge pull request #152 from dusk-network/warn-discard
Browse files Browse the repository at this point in the history
Add warning when discarding incomplete messages
  • Loading branch information
herr-seppia authored Oct 3, 2024
2 parents bf941da + 2b99e83 commit 8787919
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 14 additions & 1 deletion src/transport/encoding/raptorq/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 8787919

Please sign in to comment.