11#![ deny( missing_docs) ]
22//! This create provides helpers for building streams that turn blocks into state and state into proofs.
33
4- use std:: collections:: VecDeque ;
5- use std:: pin:: Pin ;
6- use std:: task:: Poll ;
7- use tracing:: { Instrument , debug, error, info, instrument, instrument:: Instrumented , warn} ;
8-
94use futures:: FutureExt ;
105use futures:: Stream ;
116use futures:: ready;
127use pin_project_lite:: pin_project;
8+ use std:: collections:: VecDeque ;
9+ use std:: pin:: Pin ;
10+ use std:: task:: Poll ;
11+ use tracing:: { Instrument , debug, error, info, instrument, instrument:: Instrumented , warn} ;
1312use void_types:: Block ;
1413use void_types:: Height ;
1514use void_types:: Signed ;
@@ -434,6 +433,7 @@ where
434433 * this. state_transition_func = Some ( state_transition_func) ;
435434 break Some ( ( block, derived) ) ;
436435 } else if let Some ( block) = ready ! ( this. stream. as_mut( ) . poll_next( cx) ) {
436+ // Process block.
437437 let state_transition_func = this. state_transition_func . take ( ) . unwrap ( ) ;
438438 let state = this. state . clone ( ) ;
439439 this. access_fut . set ( Some (
@@ -449,6 +449,7 @@ where
449449 . boxed ( ) ,
450450 ) ) ;
451451 } else {
452+ // Stream ended.
452453 break None ;
453454 }
454455 } )
@@ -697,12 +698,14 @@ impl Notification {
697698
698699 /// Notify all receivers.
699700 pub fn notify ( & self ) {
701+ // Ignore send error - if no receivers are listening, notification can be dropped
700702 let _ = self . tx . send ( ( ) ) ;
701703 }
702704
703705 /// Wait for a notification.
704- pub async fn wait ( & mut self ) {
705- let _ = self . rx . changed ( ) . await ;
706+ /// Returns an error if the sender has been dropped.
707+ pub async fn wait ( & mut self ) -> Result < ( ) , tokio:: sync:: watch:: error:: RecvError > {
708+ self . rx . changed ( ) . await
706709 }
707710}
708711
0 commit comments