@@ -46,6 +46,11 @@ pub(crate) enum Message<S: Scheme, V: Variant> {
4646 /// A channel to send the retrieved finalization.
4747 response : oneshot:: Sender < Option < Finalization < S , V :: Commitment > > > ,
4848 } ,
49+ /// A request to retrieve the latest processed height acknowledged by the application.
50+ GetProcessedHeight {
51+ /// A channel to send the latest processed height.
52+ response : oneshot:: Sender < Height > ,
53+ } ,
4954 /// A hint that a finalized block may be available at a given height.
5055 ///
5156 /// This triggers a network fetch if the finalization is not available locally.
@@ -63,8 +68,9 @@ pub(crate) enum Message<S: Scheme, V: Variant> {
6368 HintFinalized {
6469 /// The height of the finalization to fetch.
6570 height : Height ,
66- /// Target peers to fetch from. Added to any existing targets for this height.
67- targets : NonEmptyVec < S :: PublicKey > ,
71+ /// Target peers to fetch from. Added to any existing targets for this
72+ /// height. When `None`, the resolver may ask any peer.
73+ targets : Option < NonEmptyVec < S :: PublicKey > > ,
6874 } ,
6975 /// A request to subscribe to a block by its digest.
7076 SubscribeByDigest {
@@ -132,7 +138,7 @@ pub(crate) enum Message<S: Scheme, V: Variant> {
132138 /// Sets the sync starting point (advances if higher than current).
133139 ///
134140 /// Marshal will sync and deliver blocks starting at `floor + 1`. Data below
135- /// the floor is pruned.
141+ /// the floor is pruned when `prune_archives` is `true` .
136142 ///
137143 /// To prune data without affecting the sync starting point (say at some trailing depth
138144 /// from tip), use [Message::Prune] instead.
@@ -141,6 +147,9 @@ pub(crate) enum Message<S: Scheme, V: Variant> {
141147 SetFloor {
142148 /// The candidate floor height.
143149 height : Height ,
150+
151+ /// Whether to prune finalized archives below the new floor.
152+ prune_archives : bool ,
144153 } ,
145154 /// Prunes finalized blocks and certificates below the given height.
146155 ///
@@ -215,15 +224,23 @@ impl<S: Scheme, V: Variant> Mailbox<S, V> {
215224 . flatten ( )
216225 }
217226
227+ /// Retrieve the latest processed height acknowledged by the application.
228+ pub async fn get_processed_height ( & self ) -> Option < Height > {
229+ self . sender
230+ . request ( |response| Message :: GetProcessedHeight { response } )
231+ . await
232+ }
233+
218234 /// Hints that a finalized block may be available at the given height.
219235 ///
220236 /// This method will request the finalization from the network via the resolver
221237 /// if it is not available locally.
222238 ///
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.
239+ /// When `targets` is `Some`, only those peers are tried. This is useful when
240+ /// a specific peer claims to be ahead. If a target returns invalid data, it
241+ /// will be blocked by the resolver.
242+ ///
243+ /// When `targets` is `None`, the resolver may ask any peer.
227244 ///
228245 /// Calling this multiple times for the same height with different targets will
229246 /// add to the target set if there is an ongoing fetch, allowing more peers to be tried.
@@ -234,7 +251,7 @@ impl<S: Scheme, V: Variant> Mailbox<S, V> {
234251 /// The height must be covered by both the epocher and the provider. If the
235252 /// epocher cannot map the height to an epoch, or the provider cannot supply
236253 /// a scheme for that epoch, the hint is silently dropped.
237- pub async fn hint_finalized ( & self , height : Height , targets : NonEmptyVec < S :: PublicKey > ) {
254+ pub async fn hint_finalized ( & self , height : Height , targets : Option < NonEmptyVec < S :: PublicKey > > ) {
238255 self . sender
239256 . send_lossy ( Message :: HintFinalized { height, targets } )
240257 . await ;
@@ -346,14 +363,19 @@ impl<S: Scheme, V: Variant> Mailbox<S, V> {
346363 /// Sets the sync starting point (advances if higher than current).
347364 ///
348365 /// Marshal will sync and deliver blocks starting at `floor + 1`. Data below
349- /// the floor is pruned.
366+ /// the floor is pruned when `prune_archives` is `true` .
350367 ///
351368 /// To prune data without affecting the sync starting point (say at some trailing depth
352369 /// from tip), use [Self::prune] instead.
353370 ///
354371 /// The default floor is 0.
355- pub async fn set_floor ( & self , height : Height ) {
356- self . sender . send_lossy ( Message :: SetFloor { height } ) . await ;
372+ pub async fn set_floor ( & self , height : Height , prune_archives : bool ) {
373+ self . sender
374+ . send_lossy ( Message :: SetFloor {
375+ height,
376+ prune_archives,
377+ } )
378+ . await ;
357379 }
358380
359381 /// Prunes finalized blocks and certificates below the given height.
0 commit comments