Show / Hide Table of Contents

Class Gossip

A class gossips messages into network. Peers will be stored and managed by Kademlia DHT.

Inheritance
Object
Gossip
Implements
IDisposable
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Object.ToString()
Namespace: Libplanet.Net.Consensus
Assembly: Libplanet.Net.dll
Syntax
public class Gossip : IDisposable

Constructors

| Improve this Doc View Source

Gossip(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 Source

AsPeer

BoundPeer representation of transport used in Gossip.

Declaration
public BoundPeer AsPeer { get; }
Property Value
Type Description
BoundPeer
| Improve this Doc View Source

Peers

The list of BoundPeers in the Gossip's table.

Declaration
public IEnumerable<BoundPeer> Peers { get; }
Property Value
Type Description
IEnumerable<BoundPeer>
| Improve this Doc View Source

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 Source

AddMessage(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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

Dispose()

A class gossips messages into network. Peers will be stored and managed by Kademlia DHT.

Declaration
public void Dispose()
| Improve this Doc View Source

PublishMessage(MessageContent)

Publish given MessageContent to peers.

Declaration
public void PublishMessage(MessageContent content)
Parameters
Type Name Description
MessageContent content

A MessageContent instance to publish.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

WaitForRunningAsync()

Waits until this Gossip instance gets started to run.

Declaration
public Task WaitForRunningAsync()
Returns
Type Description
Task

A Task completed when Running property becomes true.

Implements

System.IDisposable
  • Improve this Doc
  • View Source
In This Article
Back to top Copyright © 2018–2023 Planetarium