Skip to content

Commit 29710eb

Browse files
authored
Merge pull request #86 from TheBlueMatt/2018-07-event-fixes
Fix one bug on event handling, clean up docs
2 parents 29906e7 + d7c1cfc commit 29710eb

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

fuzz/fuzz_targets/full_stack_target.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ pub fn do_test(data: &[u8]) {
263263
},
264264
7 => {
265265
if should_forward {
266-
channelmanager.process_pending_htlc_forward();
266+
channelmanager.process_pending_htlc_forwards();
267267
handler.process_events();
268268
should_forward = false;
269269
}

src/ln/channelmanager.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,10 @@ impl ChannelManager {
766766
}))
767767
}
768768

769-
pub fn process_pending_htlc_forward(&self) {
769+
/// Processes HTLCs which are pending waiting on random forward delay.
770+
/// Should only really ever be called in response to an PendingHTLCsForwardable event.
771+
/// Will likely generate further events.
772+
pub fn process_pending_htlc_forwards(&self) {
770773
let mut new_events = Vec::new();
771774
let mut failed_forwards = Vec::new();
772775
{
@@ -958,7 +961,7 @@ impl ChannelManager {
958961
pub fn claim_funds(&self, payment_preimage: [u8; 32]) -> bool {
959962
self.claim_funds_internal(payment_preimage, true)
960963
}
961-
pub fn claim_funds_internal(&self, payment_preimage: [u8; 32], from_user: bool) -> bool {
964+
fn claim_funds_internal(&self, payment_preimage: [u8; 32], from_user: bool) -> bool {
962965
let mut sha = Sha256::new();
963966
sha.input(&payment_preimage);
964967
let mut payment_hash = [0; 32];
@@ -2359,7 +2362,7 @@ mod tests {
23592362
};
23602363

23612364
node.node.channel_state.lock().unwrap().next_forward = Instant::now();
2362-
node.node.process_pending_htlc_forward();
2365+
node.node.process_pending_htlc_forwards();
23632366

23642367
let mut events_2 = node.node.get_and_clear_pending_events();
23652368
assert_eq!(events_2.len(), 1);

src/ln/peer_handler.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -628,11 +628,8 @@ impl<Descriptor: SocketDescriptor> PeerManager<Descriptor> {
628628
Event::PaymentReceived {..} => { /* Hand upstream */ },
629629
Event::PaymentSent {..} => { /* Hand upstream */ },
630630
Event::PaymentFailed {..} => { /* Hand upstream */ },
631+
Event::PendingHTLCsForwardable {..} => { /* Hand upstream */ },
631632

632-
Event::PendingHTLCsForwardable {..} => {
633-
//TODO: Handle upstream in some confused form so that upstream just knows
634-
//to call us somehow?
635-
},
636633
Event::SendOpenChannel { ref node_id, ref msg } => {
637634
let (mut descriptor, peer) = get_peer_for_forwarding!(node_id, {
638635
//TODO: Drop the pending channel? (or just let it timeout, but that sucks)
@@ -750,6 +747,7 @@ impl<Descriptor: SocketDescriptor> PeerManager<Descriptor> {
750747
descriptor.disconnect_socket();
751748
self.message_handler.chan_handler.peer_disconnected(&node_id, false);
752749
}
750+
continue;
753751
},
754752
}
755753

src/util/events.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ pub enum Event {
4646
PaymentFailed {
4747
payment_hash: [u8; 32],
4848
},
49-
50-
// Events indicating the network loop should send a message to a peer:
5149
/// Used to indicate that ChannelManager::process_pending_htlc_forwards should be called at a
5250
/// time in the future.
5351
PendingHTLCsForwardable {
5452
time_forwardable: Instant,
5553
},
54+
55+
// Events indicating the network loop should send a message to a peer:
5656
/// Used to indicate that we've initialted a channel open and should send the open_channel
5757
/// message provided to the given peer
5858
SendOpenChannel {

0 commit comments

Comments
 (0)