Skip to content

Commit

Permalink
Handle already discarded packets in discard_excess_packets (solana-la…
Browse files Browse the repository at this point in the history
  • Loading branch information
sakridge authored Jan 21, 2022
1 parent 9977396 commit 38b02bb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion core/src/sigverify_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ impl SigVerifyStage {
.iter_mut()
.rev()
.flat_map(|batch| batch.packets.iter_mut().rev())
.filter(|packet| !packet.meta.discard())
.map(|packet| (packet.meta.addr, packet))
.into_group_map();
// Allocate max_packets evenly across addresses.
Expand Down Expand Up @@ -372,11 +373,14 @@ mod tests {
let mut batch = PacketBatch::default();
batch.packets.resize(10, Packet::default());
batch.packets[3].meta.addr = std::net::IpAddr::from([1u16; 8]);
batch.packets[3].meta.set_discard(true);
batch.packets[4].meta.addr = std::net::IpAddr::from([2u16; 8]);
let mut batches = vec![batch];
let max = 3;
SigVerifyStage::discard_excess_packets(&mut batches, max);
assert_eq!(count_non_discard(&batches), max);
assert!(!batches[0].packets[0].meta.discard());
assert!(!batches[0].packets[3].meta.discard());
assert!(batches[0].packets[3].meta.discard());
assert!(!batches[0].packets[4].meta.discard());
}
}

0 comments on commit 38b02bb

Please sign in to comment.