@@ -507,6 +507,12 @@ where
507
507
self . sweeper_state . lock ( ) . unwrap ( ) . outputs . clone ( )
508
508
}
509
509
510
+ /// Gets the latest best block which was connected either via the [`Listen`] or
511
+ /// [`Confirm`] interfaces.
512
+ pub fn current_best_block ( & self ) -> BestBlock {
513
+ self . sweeper_state . lock ( ) . unwrap ( ) . best_block
514
+ }
515
+
510
516
fn regenerate_spend_if_necessary (
511
517
& self , sweeper_state : & mut SweeperState ,
512
518
) -> Option < Transaction > {
@@ -798,3 +804,56 @@ where
798
804
} )
799
805
}
800
806
}
807
+
808
+ impl < B : Deref , F : Deref , K : Deref , L : Deref >
809
+ ReadableArgs < (
810
+ B ,
811
+ Option < F > ,
812
+ K ,
813
+ L ,
814
+ Box <
815
+ dyn Fn ( & [ & SpendableOutputDescriptor ] ) -> Result < Transaction , ( ) >
816
+ + Send
817
+ + Sync
818
+ + ' static ,
819
+ > ,
820
+ ) > for ( BestBlock , OutputSweeper < B , F , K , L > )
821
+ where
822
+ B :: Target : BroadcasterInterface ,
823
+ F :: Target : Filter + Sync + Send ,
824
+ K :: Target : KVStore ,
825
+ L :: Target : Logger ,
826
+ {
827
+ #[ inline]
828
+ fn read < R : io:: Read > (
829
+ reader : & mut R ,
830
+ args : (
831
+ B ,
832
+ Option < F > ,
833
+ K ,
834
+ L ,
835
+ Box <
836
+ dyn Fn ( & [ & SpendableOutputDescriptor ] ) -> Result < Transaction , ( ) >
837
+ + Send
838
+ + Sync
839
+ + ' static ,
840
+ > ,
841
+ ) ,
842
+ ) -> Result < Self , DecodeError > {
843
+ let ( broadcaster, chain_data_source, kv_store, logger, spend_outputs_callback) = args;
844
+ let state = SweeperState :: read ( reader) ?;
845
+ let best_block = state. best_block ;
846
+ let sweeper_state = Mutex :: new ( state) ;
847
+ Ok ( (
848
+ best_block,
849
+ OutputSweeper {
850
+ sweeper_state,
851
+ broadcaster,
852
+ kv_store,
853
+ chain_data_source,
854
+ logger,
855
+ spend_outputs_callback,
856
+ } ,
857
+ ) )
858
+ }
859
+ }
0 commit comments