Handle acknowledgement from the application that a block has been processed. Buffers the processed height update but does NOT sync to durable storage. The caller must sync metadata after processing all ready acks.
(
&mut self,
height: Height,
commitment: B::Digest,
resolver: &mut impl Resolver<Key = Request<B::Digest>>,
)
| 1225 | for subscriber in bs.subscribers.drain(..) { |
| 1226 | subscriber.send_lossy(block.clone()); |
| 1227 | } |
| 1228 | } |
| 1229 | } |
| 1230 | |
| 1231 | // -------------------- Application Dispatch -------------------- |
| 1232 | |
| 1233 | /// Attempt to dispatch finalized blocks to the application until the pipeline is full |
| 1234 | /// or no more blocks are available. |
| 1235 | /// |
| 1236 | /// This does NOT advance `last_processed_height` or sync metadata. It only |
| 1237 | /// sends blocks to the application and enqueues pending acks. Metadata is |
| 1238 | /// updated later when acks arrive and [`Self::handle_block_processed`] runs. |
| 1239 | /// |
| 1240 | /// Acks are processed in FIFO order so `last_processed_height` always |
| 1241 | /// advances sequentially. |
| 1242 | async fn try_dispatch_blocks( |
| 1243 | &mut self, |
| 1244 | application: &mut impl Reporter<Activity = Update<B, P::Scheme, A>>, |
| 1245 | resolver: &mut impl Resolver<Key = Request<B::Digest>>, |
| 1246 | ) { |
| 1247 | while self.pending_acks.has_capacity() { |
| 1248 | let next_height = self |
| 1249 | .pending_acks |
| 1250 | .next_dispatch_height(self.last_processed_height); |
| 1251 | let Some(block) = self.get_finalized_block(next_height).await else { |
| 1252 | return; |
| 1253 | }; |
| 1254 | assert_eq!( |
| 1255 | block.height(), |
| 1256 | next_height, |
| 1257 | "finalized block height mismatch" |
| 1258 | ); |
| 1259 | |
| 1260 | let (height, commitment) = (block.height(), block.digest()); |
| 1261 | let (ack, ack_waiter) = A::handle(); |
| 1262 | |
| 1263 | if is_last_block_of_epoch(&self.epocher, next_height.get()) { |
| 1264 | let Some(finalization) = self.get_finalization_by_height(next_height).await else { |
nothing calls this directly
no test coverage detected