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.
*self = OnionMessageRecipient::ConnectedPeer(new_pending_messages);
}
}
+
+ fn is_connected(&self) -> bool {
+ match self {
+ OnionMessageRecipient::ConnectedPeer(..) => true,
+ OnionMessageRecipient::PendingConnection(..) => false,
+ }
+ }
}
/// An [`OnionMessage`] for [`OnionMessenger`] to send.
},
hash_map::Entry::Occupied(mut e) => {
e.get_mut().enqueue_message(onion_message);
- Ok(SendSuccess::Buffered)
+ if e.get().is_connected() {
+ Ok(SendSuccess::Buffered)
+ } else {
+ Ok(SendSuccess::BufferedAwaitingConnection(first_node_id))
+ }
},
}
}