Class PeerService
- Namespace
- NLightning.Infrastructure.Node.Services
- Assembly
- NLightning.Infrastructure.dll
Service for peer communication
public sealed class PeerService : IPeerService, IDisposable
- 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
peerCommunicationServiceIPeerCommunicationServiceThe peer communication service
featuresFeatureOptionsThe feature options
loggerILogger<PeerService>A logger
networkTimeoutTimeSpanNetwork 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(Exception?)
Disconnects from the peer.
public void Disconnect(Exception? exception = null)
Parameters
exceptionException
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
SendMessageAsync(IChannelMessage)
Sends an asynchronous message to the peer.
public Task SendMessageAsync(IChannelMessage replyMessage)
Parameters
replyMessageIChannelMessageThe message to be sent to the peer.
Returns
- Task
A task that represents the asynchronous operation.
SendWarningAsync(WarningException)
Sends a warning message to the peer.
public Task SendWarningAsync(WarningException we)
Parameters
weWarningExceptionThe warning exception containing the warning message to be sent to the peer.
Returns
- Task
A task that represents the asynchronous operation.
Events
OnAttentionMessageReceived
Occurs when an Error or Warning message is received from the connected peer.
public event EventHandler<AttentionMessageEventArgs>? OnAttentionMessageReceived
Event Type
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
Event Type
OnExceptionRaised
Occurs when an exception is raised during peer communication.
public event EventHandler<Exception>? OnExceptionRaised