mirror of
https://github.com/lightningdevkit/rust-lightning.git
synced 2025-02-22 14:33:08 +01:00
LSPS2: Clean pending get_info
request state on disconnection
We clean up any `get_info` request state when peers disconnect.
This commit is contained in:
parent
f75f124e02
commit
6451a432cc
2 changed files with 18 additions and 1 deletions
|
@ -459,6 +459,11 @@ impl PeerState {
|
|||
fn insert_outbound_channel(&mut self, intercept_scid: u64, channel: OutboundJITChannel) {
|
||||
self.outbound_channels_by_intercept_scid.insert(intercept_scid, channel);
|
||||
}
|
||||
|
||||
fn peer_disconnected(&mut self) {
|
||||
// Clean any pending `get_info` requests.
|
||||
self.pending_requests.retain(|_, entry| !matches!(entry, LSPS2Request::GetInfo(_)));
|
||||
}
|
||||
}
|
||||
|
||||
/// The main object allowing to send and receive LSPS2 messages.
|
||||
|
@ -1232,6 +1237,14 @@ where
|
|||
"total_pending_requests counter out-of-sync! This should never happen!"
|
||||
);
|
||||
}
|
||||
|
||||
pub(crate) fn peer_disconnected(&self, counterparty_node_id: PublicKey) {
|
||||
let outer_state_lock = self.per_peer_state.write().unwrap();
|
||||
if let Some(inner_state_lock) = outer_state_lock.get(&counterparty_node_id) {
|
||||
let mut peer_state_lock = inner_state_lock.lock().unwrap();
|
||||
peer_state_lock.peer_disconnected();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<CM: Deref + Clone> ProtocolMessageHandler for LSPS2ServiceHandler<CM>
|
||||
|
|
|
@ -612,7 +612,11 @@ where
|
|||
features
|
||||
}
|
||||
|
||||
fn peer_disconnected(&self, _: bitcoin::secp256k1::PublicKey) {}
|
||||
fn peer_disconnected(&self, counterparty_node_id: bitcoin::secp256k1::PublicKey) {
|
||||
if let Some(lsps2_service_handler) = self.lsps2_service_handler.as_ref() {
|
||||
lsps2_service_handler.peer_disconnected(counterparty_node_id);
|
||||
}
|
||||
}
|
||||
fn peer_connected(
|
||||
&self, _: bitcoin::secp256k1::PublicKey, _: &lightning::ln::msgs::Init, _: bool,
|
||||
) -> Result<(), ()> {
|
||||
|
|
Loading…
Add table
Reference in a new issue