Skip to content

Commit 1c4d328

Browse files
committed
Return correct SendSuccess in OnionMessenger
When enqueuing a message for a node already awaiting a connection, BufferedAwaitingConnection should be returned when a node is not yet connected as a peer. However, it was only returned when the first message was enqueued. Any messages enqueued after but before a connection was established incorrectly returned Buffered.
1 parent be618bb commit 1c4d328

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

lightning/src/onion_message/messenger.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,13 @@ impl OnionMessageRecipient {
223223
*self = OnionMessageRecipient::ConnectedPeer(new_pending_messages);
224224
}
225225
}
226+
227+
fn is_connected(&self) -> bool {
228+
match self {
229+
OnionMessageRecipient::ConnectedPeer(..) => true,
230+
OnionMessageRecipient::PendingConnection(..) => false,
231+
}
232+
}
226233
}
227234

228235
/// An [`OnionMessage`] for [`OnionMessenger`] to send.
@@ -729,7 +736,11 @@ where
729736
},
730737
hash_map::Entry::Occupied(mut e) => {
731738
e.get_mut().enqueue_message(onion_message);
732-
Ok(SendSuccess::Buffered)
739+
if e.get().is_connected() {
740+
Ok(SendSuccess::Buffered)
741+
} else {
742+
Ok(SendSuccess::BufferedAwaitingConnection(first_node_id))
743+
}
733744
},
734745
}
735746
}

0 commit comments

Comments
 (0)