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
IPeerCommunicationServiceThe peer communication service
features
FeatureOptionsThe feature options
logger
ILogger<PeerService>A logger
networkTimeout
TimeSpanNetwork timeout
Properties
Features
Gets the feature options for the peer.
public FeatureOptions Features { get; }
Property Value
PeerPubKey
Gets the peer's public key.
public CompactPubKey PeerPubKey { get; }
Property Value
PreferredHost
public string? PreferredHost { get; }
Property Value
PreferredPort
public ushort? PreferredPort { get; }
Property Value
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
IChannelMessageThe 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
OnDisconnect
Event raised when the peer is disconnected.
public event EventHandler<PeerDisconnectedEventArgs>? OnDisconnect