Class PeerManager
- Namespace
- NLightning.Application.Node.Managers
- Assembly
- NLightning.Application.dll
Service for managing peers.
public sealed class PeerManager : IPeerManager
- Inheritance
-
PeerManager
- Implements
- Inherited Members
Remarks
This class is used to manage peers in the network.
Constructors
PeerManager(IChannelManager, ILogger<PeerManager>, IPeerServiceFactory, ITcpService, IServiceProvider)
public PeerManager(IChannelManager channelManager, ILogger<PeerManager> logger, IPeerServiceFactory peerServiceFactory, ITcpService tcpService, IServiceProvider serviceProvider)
Parameters
channelManager
IChannelManagerlogger
ILogger<PeerManager>peerServiceFactory
IPeerServiceFactorytcpService
ITcpServiceserviceProvider
IServiceProvider
Methods
ConnectToPeerAsync(PeerAddressInfo)
Connects to a peer.
public Task ConnectToPeerAsync(PeerAddressInfo peerAddressInfo)
Parameters
peerAddressInfo
PeerAddressInfoThe peer address to connect to.
Returns
- Task
A task that represents the asynchronous operation.
Exceptions
- ConnectionException
Thrown when the connection to the peer fails.
DisconnectPeer(CompactPubKey)
Disconnects a peer.
public void DisconnectPeer(CompactPubKey pubKey)
Parameters
pubKey
CompactPubKey
StartAsync(CancellationToken)
Starts the peer manager asynchronously.
public Task StartAsync(CancellationToken cancellationToken)
Parameters
cancellationToken
CancellationTokenThe cancellation token to monitor for cancellation requests.
Returns
- Task
A task that represents the asynchronous operation.
StopAsync()
Stops the peer manager asynchronously.
public Task StopAsync()
Returns
- Task
A task that represents the asynchronous operation.