feat(core): Node::drain_events for confidence events

This commit is contained in:
2026-10-18 11:56:38 -07:00
parent 29c30a6b33
commit d099f09b63
2 changed files with 48 additions and 2 deletions
+14 -2
View File
@@ -11,8 +11,8 @@
//! transport frames are dropped by the [`Exchange`].
use crate::{
consts, BeliefPolicy, Exchange, NodeId, Observation, ObservationId, Payload, Store, StoreError,
Tick, Topic, Transport, TrimPolicy,
consts, BeliefPolicy, ConfidenceEvent, Exchange, NodeId, Observation, ObservationId, Payload,
Store, StoreError, Tick, Topic, Transport, TrimPolicy,
};
/// Errors returned by [`Node::observe`].
@@ -165,6 +165,18 @@ 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.
///
/// 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 }> {
self.exchange.drain_events()
}
/// The current belief for `topic_prefix` under `policy` (an empty prefix
/// matches all topics).
///