@@ -132,14 +132,12 @@ impl<
132132pub struct GossipVerifier < S : FutureSpawner ,
133133 Blocks : Deref + Send + Sync + ' static + Clone ,
134134 L : Deref + Send + Sync + ' static ,
135- APM : Deref + Send + Sync + ' static + Clone ,
136135> where
137136 Blocks :: Target : UtxoSource ,
138137 L :: Target : Logger ,
139- APM :: Target : APeerManager ,
140138{
141139 source : Blocks ,
142- peer_manager : APM ,
140+ peer_manager_wake : Arc < dyn Fn ( ) + Send + Sync > ,
143141 gossiper : Arc < P2PGossipSync < Arc < NetworkGraph < L > > , Self , L > > ,
144142 spawn : S ,
145143 block_cache : Arc < Mutex < VecDeque < ( u32 , Block ) > > > ,
@@ -150,19 +148,20 @@ const BLOCK_CACHE_SIZE: usize = 5;
150148impl < S : FutureSpawner ,
151149 Blocks : Deref + Send + Sync + Clone ,
152150 L : Deref + Send + Sync ,
153- APM : Deref + Send + Sync + Clone ,
154- > GossipVerifier < S , Blocks , L , APM > where
151+ > GossipVerifier < S , Blocks , L > where
155152 Blocks :: Target : UtxoSource ,
156153 L :: Target : Logger ,
157- APM :: Target : APeerManager ,
158154{
159155 /// Constructs a new [`GossipVerifier`].
160156 ///
161157 /// This is expected to be given to a [`P2PGossipSync`] (initially constructed with `None` for
162158 /// 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 ( ) ) ;
164163 Self {
165- source, spawn, gossiper, peer_manager ,
164+ source, spawn, gossiper, peer_manager_wake ,
166165 block_cache : Arc :: new ( Mutex :: new ( VecDeque :: with_capacity ( BLOCK_CACHE_SIZE ) ) ) ,
167166 }
168167 }
@@ -252,11 +251,9 @@ impl<S: FutureSpawner,
252251impl < S : FutureSpawner ,
253252 Blocks : Deref + Send + Sync + Clone ,
254253 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
257255 Blocks :: Target : UtxoSource ,
258256 L :: Target : Logger ,
259- APM :: Target : APeerManager ,
260257{
261258 type Target = Self ;
262259 fn deref ( & self ) -> & Self { self }
@@ -266,23 +263,21 @@ impl<S: FutureSpawner,
266263impl < S : FutureSpawner ,
267264 Blocks : Deref + Send + Sync + Clone ,
268265 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
271267 Blocks :: Target : UtxoSource ,
272268 L :: Target : Logger ,
273- APM :: Target : APeerManager ,
274269{
275270 fn get_utxo ( & self , _chain_hash : & ChainHash , short_channel_id : u64 ) -> UtxoResult {
276271 let res = UtxoFuture :: new ( ) ;
277272 let fut = res. clone ( ) ;
278273 let source = self . source . clone ( ) ;
279274 let gossiper = Arc :: clone ( & self . gossiper ) ;
280275 let block_cache = Arc :: clone ( & self . block_cache ) ;
281- let pm = self . peer_manager . clone ( ) ;
276+ let pmw = Arc :: clone ( & self . peer_manager_wake ) ;
282277 self . spawn . spawn ( async move {
283278 let res = Self :: retrieve_utxo ( source, block_cache, short_channel_id) . await ;
284279 fut. resolve ( gossiper. network_graph ( ) , & * gossiper, res) ;
285- pm . as_ref ( ) . process_events ( ) ;
280+ ( pmw ) ( ) ;
286281 } ) ;
287282 UtxoResult :: Async ( res)
288283 }
0 commit comments