Table of Contents

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 IChannelManager
logger ILogger<PeerManager>
peerServiceFactory IPeerServiceFactory
tcpService ITcpService
serviceProvider IServiceProvider

Methods

ConnectToPeerAsync(PeerAddressInfo)

Connects to a peer.

public Task<PeerModel> ConnectToPeerAsync(PeerAddressInfo peerAddressInfo)

Parameters

peerAddressInfo PeerAddressInfo

The peer address to connect to.

Returns

Task<PeerModel>

A task that represents the asynchronous operation.

Exceptions

ConnectionException

Thrown when the connection to the peer fails.

InvalidOperationException

Thrown when the connection to the peer already exists.

DisconnectPeer(CompactPubKey, Exception?)

Disconnects a peer.

public void DisconnectPeer(CompactPubKey pubKey, Exception? exception = null)

Parameters

pubKey CompactPubKey
exception Exception

Optional exception that caused the disconnection

GetPeer(CompactPubKey)

public PeerModel? GetPeer(CompactPubKey peerId)

Parameters

peerId CompactPubKey

Returns

PeerModel

ListPeers()

public List<PeerModel> ListPeers()

Returns

List<PeerModel>

StartAsync(CancellationToken)

Starts the peer manager asynchronously.

public Task StartAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

The 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.

See Also