Table of Contents

Class PeerService

Namespace
NLightning.Infrastructure.Node.Services
Assembly
NLightning.Infrastructure.dll

Service for peer communication

public sealed class PeerService : IPeerService
Inheritance
PeerService
Implements
Inherited Members

Constructors

PeerService(IPeerCommunicationService, FeatureOptions, ILogger<PeerService>, TimeSpan)

Initializes a new instance of the PeerService class.

public PeerService(IPeerCommunicationService peerCommunicationService, FeatureOptions features, ILogger<PeerService> logger, TimeSpan networkTimeout)

Parameters

peerCommunicationService IPeerCommunicationService

The peer communication service

features FeatureOptions

The feature options

logger ILogger<PeerService>

A logger

networkTimeout TimeSpan

Network timeout

Properties

Features

Gets the feature options for the peer.

public FeatureOptions Features { get; }

Property Value

FeatureOptions

PeerPubKey

Gets the peer's public key.

public CompactPubKey PeerPubKey { get; }

Property Value

CompactPubKey

PreferredHost

public string? PreferredHost { get; }

Property Value

string

PreferredPort

public ushort? PreferredPort { get; }

Property Value

ushort?

Methods

Disconnect()

Disconnects from the peer.

public void Disconnect()

SendMessageAsync(IChannelMessage)

Sends an asynchronous message to the peer.

public Task SendMessageAsync(IChannelMessage replyMessage)

Parameters

replyMessage IChannelMessage

The message to be sent to the peer.

Returns

Task

A task that represents the asynchronous operation.

Events

OnChannelMessageReceived

Occurs when a channel message is received from the connected peer.

public event EventHandler<ChannelMessageEventArgs>? OnChannelMessageReceived

Event Type

EventHandler<ChannelMessageEventArgs>

OnDisconnect

Event raised when the peer is disconnected.

public event EventHandler<PeerDisconnectedEventArgs>? OnDisconnect

Event Type

EventHandler<PeerDisconnectedEventArgs>