• Design
  • API Reference
  • Changelog
  • Contribute
Show / Hide Table of Contents
  • Libplanet
    • Address
    • AddressExtension
    • ByteUtil
    • Hashcash
    • Hashcash.Stamp
    • HashDigest<T>
    • HashDigestExtension
    • Nonce
  • Libplanet.Action
    • AccountStateGetter
    • ActionEvaluation<T>
    • ActionTypeAttribute
    • AddressStateMap
    • IAccountStateDelta
    • IAction
    • IActionContext
    • IRandom
    • MissingActionTypeException
    • PolymorphicAction<T>
  • Libplanet.Blockchain
    • BlockChain<T>
  • Libplanet.Blockchain.Policies
    • BlockPolicy<T>
    • BlockPolicyExtension
    • IBlockPolicy<T>
  • Libplanet.Blocks
    • Block<T>
    • InvalidBlockDifficultyException
    • InvalidBlockException
    • InvalidBlockHashException
    • InvalidBlockIndexException
    • InvalidBlockNonceException
    • InvalidBlockPreviousHashException
    • InvalidBlockTimestampException
  • Libplanet.Crypto
    • InvalidCiphertextException
    • PrivateKey
    • PublicKey
    • SymmetricKey
  • Libplanet.Net
    • BlockDownloadState
    • DifferentAppProtocolVersionException
    • DifferentProtocolVersionEventArgs
    • IceServer
    • IceServerException
    • InvalidMessageException
    • NoSwarmContextException
    • Peer
    • PeerNotFoundException
    • PeerSetDelta
    • Swarm
    • SwarmException
  • Libplanet.Serialization
    • BencodexFormatter<T>
    • SerializationInfoExtension
  • Libplanet.Store
    • BaseIndex<TKey, TVal>
    • BaseStore
    • BlockSet<T>
    • FileStore
    • IStore
    • NamespaceNotFoundException
    • TransactionSet<T>
  • Libplanet.Tx
    • InvalidTxException
    • InvalidTxIdException
    • InvalidTxNonceException
    • InvalidTxPublicKeyException
    • InvalidTxSignatureException
    • InvalidTxUpdatedAddressesException
    • Transaction<T>
    • TxId
    • UnexpectedlyTerminatedTxRehearsalException

Class Swarm

Inheritance
Object
Swarm
Implements
ICollection<Peer>
IEnumerable<Peer>
IEnumerable
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Object.ToString()
Namespace: Libplanet.Net
Assembly: Libplanet.dll
Syntax
public class Swarm : ICollection<Peer>, IEnumerable<Peer>, IEnumerable

Constructors

| Improve this Doc View Source

Swarm(PrivateKey, Int32, Int32, Int32, String, Nullable<Int32>, Nullable<DateTimeOffset>, IEnumerable<IceServer>, EventHandler<DifferentProtocolVersionEventArgs>)

Declaration
public Swarm(PrivateKey privateKey, int appProtocolVersion, int millisecondsDialTimeout = 15000, int millisecondsLinger = 1000, string host = null, int? listenPort = default(int? ), DateTimeOffset? createdAt = default(DateTimeOffset? ), IEnumerable<IceServer> iceServers = null, EventHandler<DifferentProtocolVersionEventArgs> differentVersionPeerEncountered = null)
Parameters
Type Name Description
PrivateKey privateKey
Int32 appProtocolVersion
Int32 millisecondsDialTimeout
Int32 millisecondsLinger
String host
Nullable<Int32> listenPort
Nullable<DateTimeOffset> createdAt
IEnumerable<IceServer> iceServers
EventHandler<DifferentProtocolVersionEventArgs> differentVersionPeerEncountered
| Improve this Doc View Source

Swarm(PrivateKey, Int32, TimeSpan, TimeSpan, String, Nullable<Int32>, Nullable<DateTimeOffset>, IEnumerable<IceServer>, EventHandler<DifferentProtocolVersionEventArgs>)

Declaration
public Swarm(PrivateKey privateKey, int appProtocolVersion, TimeSpan dialTimeout, TimeSpan linger, string host = null, int? listenPort = default(int? ), DateTimeOffset? createdAt = default(DateTimeOffset? ), IEnumerable<IceServer> iceServers = null, EventHandler<DifferentProtocolVersionEventArgs> differentVersionPeerEncountered = null)
Parameters
Type Name Description
PrivateKey privateKey
Int32 appProtocolVersion
TimeSpan dialTimeout
TimeSpan linger
String host
Nullable<Int32> listenPort
Nullable<DateTimeOffset> createdAt
IEnumerable<IceServer> iceServers
EventHandler<DifferentProtocolVersionEventArgs> differentVersionPeerEncountered

Properties

| Improve this Doc View Source

Address

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

AsPeer

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

BlockReceived

Declaration
public AsyncAutoResetEvent BlockReceived { get; }
Property Value
Type Description
Nito.AsyncEx.AsyncAutoResetEvent
| Improve this Doc View Source

Count

Declaration
public int Count { get; }
Property Value
Type Description
Int32
| Improve this Doc View Source

DeltaDistributed

Declaration
public AsyncAutoResetEvent DeltaDistributed { get; }
Property Value
Type Description
Nito.AsyncEx.AsyncAutoResetEvent
| Improve this Doc View Source

DeltaReceived

Declaration
public AsyncAutoResetEvent DeltaReceived { get; }
Property Value
Type Description
Nito.AsyncEx.AsyncAutoResetEvent
| Improve this Doc View Source

EndPoint

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

IsReadOnly

Declaration
public bool IsReadOnly { get; }
Property Value
Type Description
Boolean
| Improve this Doc View Source

LastDistributed

Declaration
public DateTimeOffset LastDistributed { get; }
Property Value
Type Description
DateTimeOffset
| 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 instance is running.

Declaration
public bool Running { get; }
Property Value
Type Description
Boolean
| Improve this Doc View Source

TxReceived

Declaration
public AsyncAutoResetEvent TxReceived { get; }
Property Value
Type Description
Nito.AsyncEx.AsyncAutoResetEvent

Methods

| Improve this Doc View Source

Add(Peer)

Declaration
public void Add(Peer item)
Parameters
Type Name Description
Peer item
| Improve this Doc View Source

AddPeersAsync(IEnumerable<Peer>, Nullable<DateTimeOffset>, CancellationToken)

Declaration
public Task<ISet<Peer>> AddPeersAsync(IEnumerable<Peer> peers, DateTimeOffset? timestamp = default(DateTimeOffset? ), CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
IEnumerable<Peer> peers
Nullable<DateTimeOffset> timestamp
CancellationToken cancellationToken
Returns
Type Description
Task<ISet<Peer>>
| Improve this Doc View Source

BroadcastBlocks<T>(IEnumerable<Block<T>>)

Declaration
public void BroadcastBlocks<T>(IEnumerable<Block<T>> blocks)
    where T : IAction, new()
Parameters
Type Name Description
IEnumerable<Block<T>> blocks
Type Parameters
Name Description
T
| Improve this Doc View Source

BroadcastTxs<T>(IEnumerable<Transaction<T>>)

Declaration
public void BroadcastTxs<T>(IEnumerable<Transaction<T>> txs)
    where T : IAction, new()
Parameters
Type Name Description
IEnumerable<Transaction<T>> txs
Type Parameters
Name Description
T
| Improve this Doc View Source

Clear()

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

Contains(Peer)

Declaration
public bool Contains(Peer item)
Parameters
Type Name Description
Peer item
Returns
Type Description
Boolean
| Improve this Doc View Source

CopyTo(Peer[], Int32)

Declaration
public void CopyTo(Peer[] array, int arrayIndex)
Parameters
Type Name Description
Peer[] array
Int32 arrayIndex
| Improve this Doc View Source

Finalize()

Declaration
protected void Finalize()
| Improve this Doc View Source

GetEnumerator()

Declaration
public IEnumerator<Peer> GetEnumerator()
Returns
Type Description
IEnumerator<Peer>
| Improve this Doc View Source

PreloadAsync<T>(BlockChain<T>, IProgress<BlockDownloadState>, CancellationToken)

Preemptively downloads blocks from registered Peers.

Declaration
public Task PreloadAsync<T>(BlockChain<T> blockChain, IProgress<BlockDownloadState> progress = null, CancellationToken cancellationToken = default(CancellationToken))
    where T : IAction, new()
Parameters
Type Name Description
BlockChain<T> blockChain

A BlockChain<T> instance to synchronize.

IProgress<BlockDownloadState> progress

An instance that receives progress updates for block downloads.

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.

Type Parameters
Name Description
T

An IAction type. It should match to BlockChain<T>'s type parameter.

| Improve this Doc View Source

Remove(Peer)

Declaration
public bool Remove(Peer item)
Parameters
Type Name Description
Peer item
Returns
Type Description
Boolean
| Improve this Doc View Source

StartAsync<T>(BlockChain<T>, Int32, CancellationToken)

Declaration
public Task StartAsync<T>(BlockChain<T> blockChain, int millisecondsDistributeInterval = 1500, CancellationToken cancellationToken = default(CancellationToken))
    where T : IAction, new()
Parameters
Type Name Description
BlockChain<T> blockChain
Int32 millisecondsDistributeInterval
CancellationToken cancellationToken
Returns
Type Description
Task
Type Parameters
Name Description
T
| Improve this Doc View Source

StartAsync<T>(BlockChain<T>, TimeSpan, CancellationToken)

Declaration
public Task StartAsync<T>(BlockChain<T> blockChain, TimeSpan distributeInterval, CancellationToken cancellationToken = default(CancellationToken))
    where T : IAction, new()
Parameters
Type Name Description
BlockChain<T> blockChain
TimeSpan distributeInterval
CancellationToken cancellationToken
Returns
Type Description
Task
Type Parameters
Name Description
T
| Improve this Doc View Source

StopAsync(CancellationToken)

Declaration
public Task StopAsync(CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type Name Description
CancellationToken cancellationToken
Returns
Type Description
Task
| Improve this Doc View Source

WaitForRunningAsync()

Waits until this Swarm instance gets started to run.

Declaration
public Task WaitForRunningAsync()
Returns
Type Description
Task

A Task completed when Running property becomes true.

Events

| Improve this Doc View Source

DifferentVersionPeerEncountered

The EventHandler called when the different version of Peer is discovered.

Declaration
public event EventHandler<DifferentProtocolVersionEventArgs> DifferentVersionPeerEncountered
Event Type
Type Description
EventHandler<DifferentProtocolVersionEventArgs>

Explicit Interface Implementations

| Improve this Doc View Source

IEnumerable.GetEnumerator()

Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Type Description
IEnumerator

Implements

System.Collections.Generic.ICollection<T>
System.Collections.Generic.IEnumerable<T>
System.Collections.IEnumerable
  • Improve this Doc
  • View Source
Back to top Copyright © 2019 Planetarium
Generated by DocFX