Skip to content

Commit 4309f47

Browse files
author
Fernando Ledesma
committed
add a function to disconnect all connected peers, closing their TCP connections
1 parent 4974e8f commit 4309f47

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,15 @@ impl Node {
656656
Ok(())
657657
}
658658

659+
/// Disconnect all connected peers, closing their TCP connections.
660+
///
661+
/// This can be called regardless of whether the node is running. Use this to ensure
662+
/// TCP connections are torn down on serverless platforms where the node may have connected
663+
/// to peers (e.g., during invoice generation) without a full `start()`/`stop()` cycle.
664+
pub fn disconnect_all_peers(&self) {
665+
self.peer_manager.disconnect_all_peers();
666+
}
667+
659668
/// Disconnects all peers, stops all running background tasks, and shuts down [`Node`].
660669
///
661670
/// After this returns most API methods will return [`Error::NotRunning`].

0 commit comments

Comments
 (0)