Skip to content

Peer Management

Peer Management

One of the first things you'll need to do when building your own Lightning node is connect to a peer. In LDK this is handled by the PeerManager.

The PeerManager has two dependencies:

  • A ChannelManager that enables it to notify peers when it wants to do things such as open channels.
  • A P2PGossipSync that understands when peers you are connected to send you gossip messages, enables you to forward messages, announce channel opens and more.

Since LDK knows nothing about your networking stack, you'll need to implement your own networking logic in order to connect to peers on the network. Provide LDK with raw TCP/IP socket data and the library will handle the rest for you.

LDK also handles a number of background tasks that need to happen periodically via BackgroundProcessor

Default Implementation

If you are developing in a Rust Tokio environment, LDK ships with a socket handling crate that let's you easily create new connections with peers.