@@ -453,6 +453,12 @@ where
453
453
self . sweeper_state . lock ( ) . unwrap ( ) . outputs . clone ( )
454
454
}
455
455
456
+ /// Gets the latest best block which was connected either via the [`Listen`] or
457
+ /// [`Confirm`] interfaces.
458
+ pub fn current_best_block ( & self ) -> BestBlock {
459
+ self . sweeper_state . lock ( ) . unwrap ( ) . best_block
460
+ }
461
+
456
462
fn regenerate_spend_if_necessary (
457
463
& self , sweeper_state : & mut SweeperState ,
458
464
) -> Option < Transaction > {
@@ -761,3 +767,56 @@ where
761
767
} )
762
768
}
763
769
}
770
+
771
+ impl < B : Deref , F : Deref , K : Deref , L : Deref >
772
+ ReadableArgs < (
773
+ B ,
774
+ Option < F > ,
775
+ K ,
776
+ L ,
777
+ Box <
778
+ dyn Fn ( & [ & SpendableOutputDescriptor ] ) -> Result < Transaction , ( ) >
779
+ + Send
780
+ + Sync
781
+ + ' static ,
782
+ > ,
783
+ ) > for ( BestBlock , OutputSweeper < B , F , K , L > )
784
+ where
785
+ B :: Target : BroadcasterInterface ,
786
+ F :: Target : Filter + Sync + Send ,
787
+ K :: Target : KVStore ,
788
+ L :: Target : Logger ,
789
+ {
790
+ #[ inline]
791
+ fn read < R : io:: Read > (
792
+ reader : & mut R ,
793
+ args : (
794
+ B ,
795
+ Option < F > ,
796
+ K ,
797
+ L ,
798
+ Box <
799
+ dyn Fn ( & [ & SpendableOutputDescriptor ] ) -> Result < Transaction , ( ) >
800
+ + Send
801
+ + Sync
802
+ + ' static ,
803
+ > ,
804
+ ) ,
805
+ ) -> Result < Self , DecodeError > {
806
+ let ( broadcaster, chain_data_source, kv_store, logger, spend_outputs_callback) = args;
807
+ let state = SweeperState :: read ( reader) ?;
808
+ let best_block = state. best_block ;
809
+ let sweeper_state = Mutex :: new ( state) ;
810
+ Ok ( (
811
+ best_block,
812
+ OutputSweeper {
813
+ sweeper_state,
814
+ broadcaster,
815
+ kv_store,
816
+ chain_data_source,
817
+ logger,
818
+ spend_outputs_callback,
819
+ } ,
820
+ ) )
821
+ }
822
+ }
0 commit comments