@@ -19,7 +19,7 @@ use bitcoin::secp256k1::Secp256k1;
19
19
use rand:: { thread_rng, Rng } ;
20
20
use std:: collections:: { hash_map, VecDeque } ;
21
21
use std:: ops:: Deref ;
22
- use std:: sync:: { Arc , Condvar , Mutex , RwLock } ;
22
+ use std:: sync:: { Arc , Condvar , Mutex } ;
23
23
use std:: time:: Duration ;
24
24
25
25
/// The event queue will be persisted under this key.
@@ -240,7 +240,7 @@ where
240
240
keys_manager : Arc < KeysManager > ,
241
241
inbound_payments : Arc < PaymentInfoStorage > ,
242
242
outbound_payments : Arc < PaymentInfoStorage > ,
243
- tokio_runtime : RwLock < Option < Arc < tokio:: runtime:: Runtime > > > ,
243
+ tokio_runtime : Arc < tokio:: runtime:: Runtime > ,
244
244
logger : L ,
245
245
_config : Arc < Config > ,
246
246
}
@@ -254,9 +254,9 @@ where
254
254
wallet : Arc < Wallet < bdk:: sled:: Tree > > , event_queue : Arc < EventQueue < K > > ,
255
255
channel_manager : Arc < ChannelManager > , network_graph : Arc < NetworkGraph > ,
256
256
keys_manager : Arc < KeysManager > , inbound_payments : Arc < PaymentInfoStorage > ,
257
- outbound_payments : Arc < PaymentInfoStorage > , logger : L , _config : Arc < Config > ,
257
+ outbound_payments : Arc < PaymentInfoStorage > , tokio_runtime : Arc < tokio:: runtime:: Runtime > ,
258
+ logger : L , _config : Arc < Config > ,
258
259
) -> Self {
259
- let tokio_runtime = RwLock :: new ( None ) ;
260
260
Self {
261
261
event_queue,
262
262
wallet,
@@ -270,14 +270,6 @@ where
270
270
_config,
271
271
}
272
272
}
273
-
274
- pub ( crate ) fn set_runtime ( & self , tokio_runtime : Arc < tokio:: runtime:: Runtime > ) {
275
- * self . tokio_runtime . write ( ) . unwrap ( ) = Some ( tokio_runtime) ;
276
- }
277
-
278
- pub ( crate ) fn drop_runtime ( & self ) {
279
- * self . tokio_runtime . write ( ) . unwrap ( ) = None ;
280
- }
281
273
}
282
274
283
275
impl < K : Deref , L : Deref > LdkEventHandler for EventHandler < K , L >
@@ -472,16 +464,10 @@ where
472
464
LdkEvent :: ProbeFailed { .. } => { }
473
465
LdkEvent :: HTLCHandlingFailed { .. } => { }
474
466
LdkEvent :: PendingHTLCsForwardable { time_forwardable } => {
475
- let locked_runtime = self . tokio_runtime . read ( ) . unwrap ( ) ;
476
- if locked_runtime. as_ref ( ) . is_none ( ) {
477
- log_error ! ( self . logger, "Failed process HTLC forwards: No runtime." ) ;
478
- unreachable ! ( "Failed process HTLC forwards: No runtime." ) ;
479
- }
480
-
481
467
let forwarding_channel_manager = self . channel_manager . clone ( ) ;
482
468
let min = time_forwardable. as_millis ( ) as u64 ;
483
469
484
- locked_runtime . as_ref ( ) . unwrap ( ) . spawn ( async move {
470
+ self . tokio_runtime . spawn ( async move {
485
471
let millis_to_sleep = thread_rng ( ) . gen_range ( min..min * 5 ) as u64 ;
486
472
tokio:: time:: sleep ( Duration :: from_millis ( millis_to_sleep) ) . await ;
487
473
0 commit comments