Class Swarm<T>
Inheritance
System.Object
Swarm<T>
Assembly: Libplanet.dll
Syntax
public class Swarm<T> : object where T : IAction, new()
Type Parameters
Constructors
|
Improve this Doc
View Source
Swarm(BlockChain<T>, PrivateKey, Int32, Int32, Int32, String, Nullable<Int32>, Nullable<DateTimeOffset>, IEnumerable<IceServer>, EventHandler<DifferentProtocolVersionEventArgs>)
Declaration
public Swarm(BlockChain<T> blockChain, PrivateKey privateKey, int appProtocolVersion, int millisecondsDialTimeout = 15000, int millisecondsLinger = 1000, string host = null, int? listenPort = null, DateTimeOffset? createdAt = null, IEnumerable<IceServer> iceServers = null, EventHandler<DifferentProtocolVersionEventArgs> differentVersionPeerEncountered = null)
Parameters
Type |
Name |
Description |
BlockChain<T> |
blockChain |
|
PrivateKey |
privateKey |
|
System.Int32 |
appProtocolVersion |
|
System.Int32 |
millisecondsDialTimeout |
|
System.Int32 |
millisecondsLinger |
|
System.String |
host |
|
System.Nullable<System.Int32> |
listenPort |
|
System.Nullable<DateTimeOffset> |
createdAt |
|
IEnumerable<IceServer> |
iceServers |
|
EventHandler<DifferentProtocolVersionEventArgs> |
differentVersionPeerEncountered |
|
|
Improve this Doc
View Source
Swarm(BlockChain<T>, PrivateKey, Int32, TimeSpan, TimeSpan, String, Nullable<Int32>, Nullable<DateTimeOffset>, IEnumerable<IceServer>, EventHandler<DifferentProtocolVersionEventArgs>)
Declaration
public Swarm(BlockChain<T> blockChain, PrivateKey privateKey, int appProtocolVersion, TimeSpan dialTimeout, TimeSpan linger, string host = null, int? listenPort = null, DateTimeOffset? createdAt = null, IEnumerable<IceServer> iceServers = null, EventHandler<DifferentProtocolVersionEventArgs> differentVersionPeerEncountered = null)
Parameters
Type |
Name |
Description |
BlockChain<T> |
blockChain |
|
PrivateKey |
privateKey |
|
System.Int32 |
appProtocolVersion |
|
TimeSpan |
dialTimeout |
|
TimeSpan |
linger |
|
System.String |
host |
|
System.Nullable<System.Int32> |
listenPort |
|
System.Nullable<DateTimeOffset> |
createdAt |
|
IEnumerable<IceServer> |
iceServers |
|
EventHandler<DifferentProtocolVersionEventArgs> |
differentVersionPeerEncountered |
|
Properties
|
Improve this Doc
View Source
Address
Declaration
public Address Address { get; }
Property Value
|
Improve this Doc
View Source
AsPeer
Declaration
public Peer AsPeer { get; }
Property Value
|
Improve this Doc
View Source
BlockChain
Declaration
public BlockChain<T> BlockChain { get; }
Property Value
|
Improve this Doc
View Source
BlockReceived
Declaration
public AsyncAutoResetEvent BlockReceived { get; }
Property Value
Type |
Description |
AsyncAutoResetEvent |
|
|
Improve this Doc
View Source
EndPoint
Declaration
public DnsEndPoint EndPoint { get; }
Property Value
Type |
Description |
DnsEndPoint |
|
|
Improve this Doc
View Source
LastReceived
Declaration
public DateTimeOffset LastReceived { get; }
Property Value
Type |
Description |
DateTimeOffset |
|
|
Improve this Doc
View Source
LastSeenTimestamps
Declaration
public IDictionary<Peer, DateTimeOffset> LastSeenTimestamps { get; }
Property Value
Type |
Description |
IDictionary<Peer, DateTimeOffset> |
|
|
Improve this Doc
View Source
Running
Whether this Swarm<T> instance is running.
Declaration
public bool Running { get; }
Property Value
Type |
Description |
System.Boolean |
|
|
Improve this Doc
View Source
TxReceived
Declaration
public AsyncAutoResetEvent TxReceived { get; }
Property Value
Type |
Description |
AsyncAutoResetEvent |
|
Methods
|
Improve this Doc
View Source
BootstrapAsync(IEnumerable<Peer>, Double, Double, CancellationToken)
Declaration
public Task BootstrapAsync(IEnumerable<Peer> seedPeers, double pingSeedTimeout, double findPeerTimeout, CancellationToken cancellationToken = null)
Parameters
Type |
Name |
Description |
IEnumerable<Peer> |
seedPeers |
|
System.Double |
pingSeedTimeout |
|
System.Double |
findPeerTimeout |
|
CancellationToken |
cancellationToken |
|
Returns
|
Improve this Doc
View Source
BootstrapAsync(IEnumerable<Peer>, Nullable<TimeSpan>, Nullable<TimeSpan>, CancellationToken)
Join to the peer-to-peer network using seed peers.
Declaration
public Task BootstrapAsync(IEnumerable<Peer> seedPeers, TimeSpan? pingSeedTimeout, TimeSpan? findNeighborsTimeout, CancellationToken cancellationToken = null)
Parameters
Type |
Name |
Description |
IEnumerable<Peer> |
seedPeers |
List of seed peers.
|
System.Nullable<TimeSpan> |
pingSeedTimeout |
Timeout for connecting to seed peers.
|
System.Nullable<TimeSpan> |
findNeighborsTimeout |
Timeout for requesting neighbors.
|
CancellationToken |
cancellationToken |
A cancellation token used to propagate notification
that this operation should be canceled.
|
Returns
Type |
Description |
Task |
An awaitable task without value.
|
Exceptions
|
Improve this Doc
View Source
BroadcastBlocks(IEnumerable<Block<T>>)
Declaration
public void BroadcastBlocks(IEnumerable<Block<T>> blocks)
Parameters
Type |
Name |
Description |
IEnumerable<Block<T>> |
blocks |
|
|
Improve this Doc
View Source
BroadcastTxs(IEnumerable<Transaction<T>>)
Declaration
public void BroadcastTxs(IEnumerable<Transaction<T>> txs)
Parameters
|
Improve this Doc
View Source
Finalize()
Declaration
protected void Finalize()
|
Improve this Doc
View Source
PreloadAsync(IProgress<PreloadState>, IImmutableSet<Address>, CancellationToken)
Preemptively downloads blocks from registered Peers.
Declaration
public Task PreloadAsync(IProgress<PreloadState> progress = null, IImmutableSet<Address> trustedStateValidators = null, CancellationToken cancellationToken = null)
Parameters
Type |
Name |
Description |
IProgress<PreloadState> |
progress |
An instance that receives progress updates for block downloads.
|
IImmutableSet<Address> |
trustedStateValidators |
If any peer in this set is reachable and there are no built-up
blocks in a current node, Swarm<T> receives the latest
states of the major blockchain from that trusted peer,
which is also calculated by that peer, instead of autonomously
calculating the states from scratch. Note that this option is
intended to be exposed to end users through a feasible user
interface so that they can decide whom to trust for themselves.
|
CancellationToken |
cancellationToken |
A cancellation token used to propagate notification that this
operation should be canceled.
|
Returns
Type |
Description |
Task |
A task without value.
You only can await until the method is completed.
|
|
Improve this Doc
View Source
StartAsync(Int32, CancellationToken)
Declaration
public Task StartAsync(int millisecondsBroadcastTxInterval = 5000, CancellationToken cancellationToken = null)
Parameters
Type |
Name |
Description |
System.Int32 |
millisecondsBroadcastTxInterval |
|
CancellationToken |
cancellationToken |
|
Returns
|
Improve this Doc
View Source
StartAsync(TimeSpan, CancellationToken)
Starts to periodically synchronize the BlockChain.
Declaration
public Task StartAsync(TimeSpan broadcastTxInterval, CancellationToken cancellationToken = null)
Parameters
Type |
Name |
Description |
TimeSpan |
broadcastTxInterval |
The time period of exchange of staged transactions.
|
CancellationToken |
cancellationToken |
A cancellation token used to propagate notification that this
operation should be canceled.
|
Returns
Type |
Description |
Task |
An awaitable task without value.
|
Exceptions
|
Improve this Doc
View Source
StopAsync(CancellationToken)
Declaration
public Task StopAsync(CancellationToken cancellationToken = null)
Parameters
Type |
Name |
Description |
CancellationToken |
cancellationToken |
|
Returns
|
Improve this Doc
View Source
TraceTable()
Declaration
public string TraceTable()
Returns
Type |
Description |
System.String |
|
|
Improve this Doc
View Source
WaitForRunningAsync()
Waits until this Swarm<T> instance gets started to run.
Declaration
public Task WaitForRunningAsync()
Returns
Type |
Description |
Task |
A completed when Running
property becomes true .
|
Events
|
Improve this Doc
View Source
DifferentVersionPeerEncountered
The called when the different version of
Peer is discovered.
Declaration
public event EventHandler<DifferentProtocolVersionEventArgs> DifferentVersionPeerEncountered
Event Type