X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Fmain.rs;h=37d464a96c3eaeea37d3e2d7ef6e3d14032b1b99;hb=80916829ec20eb8a510462e765a03c3ed051f2e0;hp=421db95ef833da8142462d3a93f19f01a96df884;hpb=25a4f605443ed2bc2bb9548f5679a86fc76d0333;p=ldk-sample diff --git a/src/main.rs b/src/main.rs index 421db95..37d464a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -130,6 +130,7 @@ fn handle_ldk_events(peer_manager: Arc, channel_manager: Arc, channel_manager: Arc { + Event::PaymentFailed { payment_hash, rejected_by_dest } => { print!("\nNEW EVENT: Failed to send payment to payment hash {:?}: ", hex_utils::hex_str(&payment_hash.0)); if rejected_by_dest { @@ -189,8 +190,14 @@ fn handle_ldk_events(peer_manager: Arc, channel_manager: Arc { - loop_channel_manager.process_pending_htlc_forwards(); + Event::PendingHTLCsForwardable { time_forwardable } => { + let forwarding_channel_manager = loop_channel_manager.clone(); + thread::spawn(move || { + let min = time_forwardable.as_secs(); + let seconds_to_sleep = thread_rng().gen_range(min, min * 5); + thread::sleep(Duration::new(seconds_to_sleep, 0)); + forwarding_channel_manager.process_pending_htlc_forwards(); + }); }, Event::SpendableOutputs { outputs } => { let destination_address = bitcoind_client.get_new_address();