@@ -10,10 +10,7 @@ use crate::{
1010} ;
1111use commonware_cryptography:: { certificate:: Scheme , Digestible } ;
1212use commonware_p2p:: Recipients ;
13- use commonware_utils:: {
14- channel:: { fallible:: AsyncFallibleExt , mpsc, oneshot} ,
15- vec:: NonEmptyVec ,
16- } ;
13+ use commonware_utils:: channel:: { fallible:: AsyncFallibleExt , mpsc, oneshot} ;
1714
1815/// Messages sent to the marshal [Actor](super::Actor).
1916///
@@ -46,6 +43,11 @@ pub(crate) enum Message<S: Scheme, V: Variant> {
4643 /// A channel to send the retrieved finalization.
4744 response : oneshot:: Sender < Option < Finalization < S , V :: Commitment > > > ,
4845 } ,
46+ /// A request to retrieve the latest processed height acknowledged by the application.
47+ GetProcessedHeight {
48+ /// A channel to send the latest processed height.
49+ response : oneshot:: Sender < Height > ,
50+ } ,
4951 /// A hint that a finalized block may be available at a given height.
5052 ///
5153 /// This triggers a network fetch if the finalization is not available locally.
@@ -63,8 +65,9 @@ pub(crate) enum Message<S: Scheme, V: Variant> {
6365 HintFinalized {
6466 /// The height of the finalization to fetch.
6567 height : Height ,
66- /// Target peers to fetch from. Added to any existing targets for this height.
67- targets : NonEmptyVec < S :: PublicKey > ,
68+ /// Target peers to fetch from. Added to any existing targets for this
69+ /// height.
70+ targets : Recipients < S :: PublicKey > ,
6871 } ,
6972 /// A request to subscribe to a block by its digest.
7073 SubscribeByDigest {
@@ -132,7 +135,7 @@ pub(crate) enum Message<S: Scheme, V: Variant> {
132135 /// Sets the sync starting point (advances if higher than current).
133136 ///
134137 /// Marshal will sync and deliver blocks starting at `floor + 1`. Data below
135- /// the floor is pruned.
138+ /// the floor is pruned when `prune_archives` is `true` .
136139 ///
137140 /// To prune data without affecting the sync starting point (say at some trailing depth
138141 /// from tip), use [Message::Prune] instead.
@@ -141,6 +144,9 @@ pub(crate) enum Message<S: Scheme, V: Variant> {
141144 SetFloor {
142145 /// The candidate floor height.
143146 height : Height ,
147+
148+ /// Whether to prune finalized archives below the new floor.
149+ prune_archives : bool ,
144150 } ,
145151 /// Prunes finalized blocks and certificates below the given height.
146152 ///
@@ -215,16 +221,18 @@ impl<S: Scheme, V: Variant> Mailbox<S, V> {
215221 . flatten ( )
216222 }
217223
224+ /// Retrieve the latest processed height acknowledged by the application.
225+ pub async fn get_processed_height ( & self ) -> Option < Height > {
226+ self . sender
227+ . request ( |response| Message :: GetProcessedHeight { response } )
228+ . await
229+ }
230+
218231 /// Hints that a finalized block may be available at the given height.
219232 ///
220233 /// This method will request the finalization from the network via the resolver
221234 /// if it is not available locally.
222235 ///
223- /// Targets are required because this is typically called when a peer claims to be
224- /// ahead. By targeting only those peers, we limit who we ask. If a target returns
225- /// invalid data, they will be blocked by the resolver. If targets don't respond
226- /// or return "no data", they effectively rate-limit themselves.
227- ///
228236 /// Calling this multiple times for the same height with different targets will
229237 /// add to the target set if there is an ongoing fetch, allowing more peers to be tried.
230238 ///
@@ -234,7 +242,7 @@ impl<S: Scheme, V: Variant> Mailbox<S, V> {
234242 /// The height must be covered by both the epocher and the provider. If the
235243 /// epocher cannot map the height to an epoch, or the provider cannot supply
236244 /// a scheme for that epoch, the hint is silently dropped.
237- pub async fn hint_finalized ( & self , height : Height , targets : NonEmptyVec < S :: PublicKey > ) {
245+ pub async fn hint_finalized ( & self , height : Height , targets : Recipients < S :: PublicKey > ) {
238246 self . sender
239247 . send_lossy ( Message :: HintFinalized { height, targets } )
240248 . await ;
@@ -346,14 +354,19 @@ impl<S: Scheme, V: Variant> Mailbox<S, V> {
346354 /// Sets the sync starting point (advances if higher than current).
347355 ///
348356 /// Marshal will sync and deliver blocks starting at `floor + 1`. Data below
349- /// the floor is pruned.
357+ /// the floor is pruned when `prune_archives` is `true` .
350358 ///
351359 /// To prune data without affecting the sync starting point (say at some trailing depth
352360 /// from tip), use [Self::prune] instead.
353361 ///
354362 /// The default floor is 0.
355- pub async fn set_floor ( & self , height : Height ) {
356- self . sender . send_lossy ( Message :: SetFloor { height } ) . await ;
363+ pub async fn set_floor ( & self , height : Height , prune_archives : bool ) {
364+ self . sender
365+ . send_lossy ( Message :: SetFloor {
366+ height,
367+ prune_archives,
368+ } )
369+ . await ;
357370 }
358371
359372 /// Prunes finalized blocks and certificates below the given height.
0 commit comments