Class Gossip
A class gossips messages into network. Peers will be stored and managed by Kademlia DHT.
Implements
Inherited Members
Namespace: Libplanet.Net.Consensus
Assembly: Libplanet.Net.dll
Syntax
public class Gossip : IDisposable
Constructors
| Improve this Doc View SourceGossip(ITransport, ImmutableArray<BoundPeer>, ImmutableArray<BoundPeer>, Action<MessageContent>, TimeSpan, Nullable<Int64>)
Creates a Gossip instance.
Declaration
public Gossip(ITransport transport, ImmutableArray<BoundPeer> peers, ImmutableArray<BoundPeer> seeds, Action<MessageContent> processMessage, TimeSpan seenTtl, long? seenCacheLimit = null)
Parameters
Type | Name | Description |
---|---|---|
ITransport | transport | An ITransport used for communicating messages. |
ImmutableArray<BoundPeer> | peers | A list of BoundPeer composing network. |
ImmutableArray<BoundPeer> | seeds | A list of BoundPeer for lookup network. |
Action<MessageContent> | processMessage | Action to be called when receiving a new message. |
TimeSpan | seenTtl | Time To Live of each entry of the seen cache. 2 minutes is recommended. |
Nullable<Int64> | seenCacheLimit | The size limit of the seen cache in byte. |
Properties
| Improve this Doc View SourceAsPeer
Declaration
public BoundPeer AsPeer { get; }
Property Value
Type | Description |
---|---|
BoundPeer |
Peers
Declaration
public IEnumerable<BoundPeer> Peers { get; }
Property Value
Type | Description |
---|---|
IEnumerable<BoundPeer> |
Running
Whether this Gossip instance is running.
Declaration
public bool Running { get; }
Property Value
Type | Description |
---|---|
Boolean | Gets the value indicates whether the instance is running. |
Methods
| Improve this Doc View SourceAddMessage(MessageContent)
Process a MessageContent and add it to the gossip.
Declaration
public void AddMessage(MessageContent content)
Parameters
Type | Name | Description |
---|---|---|
MessageContent | content | A MessageContent instance to process and gossip. |
AddMessages(IEnumerable<MessageContent>)
Adds multiple MessageContents in parallel. AddMessage(MessageContent)
Declaration
public void AddMessages(IEnumerable<MessageContent> contents)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<MessageContent> | contents | An enumerable MessageContent instance to process and gossip. |
Dispose()
A class gossips messages into network. Peers will be stored and managed by Kademlia DHT.
Declaration
public void Dispose()
PublishMessage(MessageContent)
Publish given MessageContent to peers.
Declaration
public void PublishMessage(MessageContent content)
Parameters
Type | Name | Description |
---|---|---|
MessageContent | content | A MessageContent instance to publish. |
StartAsync(CancellationToken)
Start the Gossip instance.
Declaration
public async Task StartAsync(CancellationToken ctx)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | ctx | A cancellation token used to propagate notification that this operation should be canceled. |
Returns
Type | Description |
---|---|
Task | An awaitable task without value. |
StopAsync(TimeSpan, CancellationToken)
Stop the Gossip instance.
Declaration
public async Task StopAsync(TimeSpan waitFor, CancellationToken ctx)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | waitFor | The TimeSpan of delay before actual stopping. |
CancellationToken | ctx | A cancellation token used to propagate notification that this operation should be canceled. |
Returns
Type | Description |
---|---|
Task | An awaitable task without value. |
WaitForRunningAsync()
Waits until this Gossip instance gets started to run.
Declaration
public Task WaitForRunningAsync()
Returns
Type | Description |
---|---|
Task |