@@ -10,14 +10,16 @@ use bitcoin::network::constants::Network;
10
10
11
11
use lightning:: chain;
12
12
13
+ use std:: ops:: Deref ;
14
+
13
15
/// Returns a validated block header of the source's best chain tip.
14
16
///
15
17
/// Upon success, the returned header can be used to initialize [`SpvClient`]. Useful during a fresh
16
18
/// start when there are no chain listeners to sync yet.
17
19
///
18
20
/// [`SpvClient`]: crate::SpvClient
19
- pub async fn validate_best_block_header < B : BlockSource > ( block_source : & B ) ->
20
- BlockSourceResult < ValidatedBlockHeader > {
21
+ pub async fn validate_best_block_header < B : Deref > ( block_source : B ) ->
22
+ BlockSourceResult < ValidatedBlockHeader > where B :: Target : BlockSource {
21
23
let ( best_block_hash, best_block_height) = block_source. get_best_block ( ) . await ?;
22
24
block_source
23
25
. get_header ( & best_block_hash, best_block_height) . await ?
@@ -121,13 +123,13 @@ BlockSourceResult<ValidatedBlockHeader> {
121
123
/// [`SpvClient`]: crate::SpvClient
122
124
/// [`ChannelManager`]: lightning::ln::channelmanager::ChannelManager
123
125
/// [`ChannelMonitor`]: lightning::chain::channelmonitor::ChannelMonitor
124
- pub async fn synchronize_listeners < ' a , B : BlockSource , C : Cache , L : chain:: Listen + ?Sized > (
125
- block_source : & B ,
126
+ pub async fn synchronize_listeners < ' a , B : Deref + Sized + Send + Sync , C : Cache , L : chain:: Listen + ?Sized > (
127
+ block_source : B ,
126
128
network : Network ,
127
129
header_cache : & mut C ,
128
130
mut chain_listeners : Vec < ( BlockHash , & ' a L ) > ,
129
- ) -> BlockSourceResult < ValidatedBlockHeader > {
130
- let best_header = validate_best_block_header ( block_source) . await ?;
131
+ ) -> BlockSourceResult < ValidatedBlockHeader > where B :: Target : BlockSource {
132
+ let best_header = validate_best_block_header ( & * block_source) . await ?;
131
133
132
134
// Fetch the header for the block hash paired with each listener.
133
135
let mut chain_listeners_with_old_headers = Vec :: new ( ) ;
0 commit comments