feat(core): NodeEvent with counted drop reporting
This commit is contained in:
+14
-9
@@ -11,8 +11,8 @@
|
||||
//! transport frames are dropped by the [`Exchange`].
|
||||
|
||||
use crate::{
|
||||
consts, BeliefPolicy, ConfidenceEvent, Exchange, NodeId, Observation, ObservationId, Payload,
|
||||
Store, StoreError, Tick, Topic, Transport, TrimPolicy,
|
||||
consts, BeliefPolicy, Exchange, NodeEvent, NodeId, Observation, ObservationId, Payload, Store,
|
||||
StoreError, Tick, Topic, Transport, TrimPolicy,
|
||||
};
|
||||
|
||||
/// Errors returned by [`Node::observe`].
|
||||
@@ -165,15 +165,20 @@ impl<S: Store, T: Transport> Node<S, T> {
|
||||
stored
|
||||
}
|
||||
|
||||
/// Drains the buffered [`ConfidenceEvent`]s the [`Exchange`] has collected
|
||||
/// as a peer acknowledged holding one of our broadcasts, oldest-first.
|
||||
/// Drains the [`NodeEvent`]s the [`Exchange`] has collected: confirmed
|
||||
/// deliveries first (oldest-first), then one [`NodeEvent::Dropped`] per
|
||||
/// counted drop.
|
||||
///
|
||||
/// The returned [`heapless::Vec`] is capped at
|
||||
/// [`consts::EVENT_QUEUE_CAP`] entries and is empty once drained (a second
|
||||
/// drain yields nothing). Index it directly — [`ConfidenceEvent::peer`]
|
||||
/// names who received our broadcast and [`ConfidenceEvent::id`] is the
|
||||
/// broadcast's content-ID.
|
||||
pub fn drain_events(&mut self) -> heapless::Vec<ConfidenceEvent, { consts::EVENT_QUEUE_CAP }> {
|
||||
/// [`consts::EVENT_QUEUE_CAP`] confirmed deliveries plus the entire
|
||||
/// [`consts::DROP_TABLE_CAP`]-entry drop table and its overflow slot. Index
|
||||
/// it directly — a [`NodeEvent::Delivered`] names the peer that held our
|
||||
/// broadcast and the broadcast's content-ID; a [`NodeEvent::Dropped`] names
|
||||
/// the peer and reason a dropped frame was rejected with.
|
||||
pub fn drain_events(
|
||||
&mut self,
|
||||
) -> heapless::Vec<NodeEvent<T::Addr>, { consts::EVENT_QUEUE_CAP + consts::DROP_TABLE_CAP + 1 }>
|
||||
{
|
||||
self.exchange.drain_events()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user