@@ -132,14 +132,12 @@ impl<
132
132
pub struct GossipVerifier < S : FutureSpawner ,
133
133
Blocks : Deref + Send + Sync + ' static + Clone ,
134
134
L : Deref + Send + Sync + ' static ,
135
- APM : Deref + Send + Sync + ' static + Clone ,
136
135
> where
137
136
Blocks :: Target : UtxoSource ,
138
137
L :: Target : Logger ,
139
- APM :: Target : APeerManager ,
140
138
{
141
139
source : Blocks ,
142
- peer_manager : APM ,
140
+ peer_manager_wake : Arc < dyn Fn ( ) + Send + Sync > ,
143
141
gossiper : Arc < P2PGossipSync < Arc < NetworkGraph < L > > , Self , L > > ,
144
142
spawn : S ,
145
143
block_cache : Arc < Mutex < VecDeque < ( u32 , Block ) > > > ,
@@ -150,19 +148,20 @@ const BLOCK_CACHE_SIZE: usize = 5;
150
148
impl < S : FutureSpawner ,
151
149
Blocks : Deref + Send + Sync + Clone ,
152
150
L : Deref + Send + Sync ,
153
- APM : Deref + Send + Sync + Clone ,
154
- > GossipVerifier < S , Blocks , L , APM > where
151
+ > GossipVerifier < S , Blocks , L > where
155
152
Blocks :: Target : UtxoSource ,
156
153
L :: Target : Logger ,
157
- APM :: Target : APeerManager ,
158
154
{
159
155
/// Constructs a new [`GossipVerifier`].
160
156
///
161
157
/// This is expected to be given to a [`P2PGossipSync`] (initially constructed with `None` for
162
158
/// the UTXO lookup) via [`P2PGossipSync::add_utxo_lookup`].
163
- pub fn new ( source : Blocks , spawn : S , gossiper : Arc < P2PGossipSync < Arc < NetworkGraph < L > > , Self , L > > , peer_manager : APM ) -> Self {
159
+ pub fn new < APM : Deref + Send + Sync + Clone + ' static > (
160
+ source : Blocks , spawn : S , gossiper : Arc < P2PGossipSync < Arc < NetworkGraph < L > > , Self , L > > , peer_manager : APM
161
+ ) -> Self where APM :: Target : APeerManager {
162
+ let peer_manager_wake = Arc :: new ( move || peer_manager. as_ref ( ) . process_events ( ) ) ;
164
163
Self {
165
- source, spawn, gossiper, peer_manager ,
164
+ source, spawn, gossiper, peer_manager_wake ,
166
165
block_cache : Arc :: new ( Mutex :: new ( VecDeque :: with_capacity ( BLOCK_CACHE_SIZE ) ) ) ,
167
166
}
168
167
}
@@ -252,11 +251,9 @@ impl<S: FutureSpawner,
252
251
impl < S : FutureSpawner ,
253
252
Blocks : Deref + Send + Sync + Clone ,
254
253
L : Deref + Send + Sync ,
255
- APM : Deref + Send + Sync + Clone ,
256
- > Deref for GossipVerifier < S , Blocks , L , APM > where
254
+ > Deref for GossipVerifier < S , Blocks , L > where
257
255
Blocks :: Target : UtxoSource ,
258
256
L :: Target : Logger ,
259
- APM :: Target : APeerManager ,
260
257
{
261
258
type Target = Self ;
262
259
fn deref ( & self ) -> & Self { self }
@@ -266,23 +263,21 @@ impl<S: FutureSpawner,
266
263
impl < S : FutureSpawner ,
267
264
Blocks : Deref + Send + Sync + Clone ,
268
265
L : Deref + Send + Sync ,
269
- APM : Deref + Send + Sync + Clone ,
270
- > UtxoLookup for GossipVerifier < S , Blocks , L , APM > where
266
+ > UtxoLookup for GossipVerifier < S , Blocks , L > where
271
267
Blocks :: Target : UtxoSource ,
272
268
L :: Target : Logger ,
273
- APM :: Target : APeerManager ,
274
269
{
275
270
fn get_utxo ( & self , _chain_hash : & ChainHash , short_channel_id : u64 ) -> UtxoResult {
276
271
let res = UtxoFuture :: new ( ) ;
277
272
let fut = res. clone ( ) ;
278
273
let source = self . source . clone ( ) ;
279
274
let gossiper = Arc :: clone ( & self . gossiper ) ;
280
275
let block_cache = Arc :: clone ( & self . block_cache ) ;
281
- let pm = self . peer_manager . clone ( ) ;
276
+ let pmw = Arc :: clone ( & self . peer_manager_wake ) ;
282
277
self . spawn . spawn ( async move {
283
278
let res = Self :: retrieve_utxo ( source, block_cache, short_channel_id) . await ;
284
279
fut. resolve ( gossiper. network_graph ( ) , & * gossiper, res) ;
285
- pm . as_ref ( ) . process_events ( ) ;
280
+ ( pmw ) ( ) ;
286
281
} ) ;
287
282
UtxoResult :: Async ( res)
288
283
}
0 commit comments