From: Matt Corallo Date: Wed, 25 Jul 2018 02:08:18 +0000 (-0400) Subject: PendingHTLCsForwardable really should just be upstreamed. X-Git-Tag: v0.0.12~369^2~2 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=af5c6e8186d1e8297f4a828901fae589d5cfcc76;p=rust-lightning PendingHTLCsForwardable really should just be upstreamed. This is just a comment/docs/function rename change --- diff --git a/fuzz/fuzz_targets/full_stack_target.rs b/fuzz/fuzz_targets/full_stack_target.rs index 59f9d2bb4..6fdac8ad2 100644 --- a/fuzz/fuzz_targets/full_stack_target.rs +++ b/fuzz/fuzz_targets/full_stack_target.rs @@ -263,7 +263,7 @@ pub fn do_test(data: &[u8]) { }, 7 => { if should_forward { - channelmanager.process_pending_htlc_forward(); + channelmanager.process_pending_htlc_forwards(); handler.process_events(); should_forward = false; } diff --git a/src/ln/channelmanager.rs b/src/ln/channelmanager.rs index 174f63cc7..8eb91ea5d 100644 --- a/src/ln/channelmanager.rs +++ b/src/ln/channelmanager.rs @@ -766,7 +766,10 @@ impl ChannelManager { })) } - pub fn process_pending_htlc_forward(&self) { + /// Processes HTLCs which are pending waiting on random forward delay. + /// Should only really ever be called in response to an PendingHTLCsForwardable event. + /// Will likely generate further events. + pub fn process_pending_htlc_forwards(&self) { let mut new_events = Vec::new(); let mut failed_forwards = Vec::new(); { @@ -2359,7 +2362,7 @@ mod tests { }; node.node.channel_state.lock().unwrap().next_forward = Instant::now(); - node.node.process_pending_htlc_forward(); + node.node.process_pending_htlc_forwards(); let mut events_2 = node.node.get_and_clear_pending_events(); assert_eq!(events_2.len(), 1); diff --git a/src/ln/peer_handler.rs b/src/ln/peer_handler.rs index 7fde10d09..7e213c037 100644 --- a/src/ln/peer_handler.rs +++ b/src/ln/peer_handler.rs @@ -628,11 +628,8 @@ impl PeerManager { Event::PaymentReceived {..} => { /* Hand upstream */ }, Event::PaymentSent {..} => { /* Hand upstream */ }, Event::PaymentFailed {..} => { /* Hand upstream */ }, + Event::PendingHTLCsForwardable {..} => { /* Hand upstream */ }, - Event::PendingHTLCsForwardable {..} => { - //TODO: Handle upstream in some confused form so that upstream just knows - //to call us somehow? - }, Event::SendOpenChannel { ref node_id, ref msg } => { let (mut descriptor, peer) = get_peer_for_forwarding!(node_id, { //TODO: Drop the pending channel? (or just let it timeout, but that sucks) diff --git a/src/util/events.rs b/src/util/events.rs index fd801e411..e8330b7e2 100644 --- a/src/util/events.rs +++ b/src/util/events.rs @@ -46,13 +46,13 @@ pub enum Event { PaymentFailed { payment_hash: [u8; 32], }, - - // Events indicating the network loop should send a message to a peer: /// Used to indicate that ChannelManager::process_pending_htlc_forwards should be called at a /// time in the future. PendingHTLCsForwardable { time_forwardable: Instant, }, + + // Events indicating the network loop should send a message to a peer: /// Used to indicate that we've initialted a channel open and should send the open_channel /// message provided to the given peer SendOpenChannel {