PeerNetwork class

Interface controlling (re)connection policy for a collection of Peers. Defines a type of network via createPeerWithSpec, e.g. CruzPeerNetwork.



PeerNetwork(VoidCallback peerChanged, VoidCallback tipChanged, {int autoReconnectSeconds: 15})


autoReconnectSeconds int
Triggers reconnectPeer on PeerState.disconnected.
read / write
awaitingPeers Queue<Completer<Peer>>
Queue of subscribes waiting for a Peer.
read / write
connecting List<Peer>
The Peer we're trying to connect to.
read / write
currency Currency
The Currency for this network.
read / write
hashCode int
The hash code for this object. [...]
read-only, inherited
hasPeer bool
True if a Peer is connected.
length int
Number of Peer either connecting or connected.
minAmount num
The minimum Transaction.amount that the network allows.
minFee num
The minimum Transaction.fee that the network allows.
peerAddress String
Peer.address from peers or empty String if none.
peerChanged VoidCallback
Notifies on any changes to peers.
read / write
peers List<Peer>
The Peer we've connected to.
read / write
peerState PeerState
Peer.state from peers or PeerState.disconnected if none.
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
tipChanged VoidCallback
Notifies when new Blocks are mined.
read / write
tipHeight int
Block.height of the most recently mined Block.
tipId BlockId
BlockId of the most recently mined Block.


addPeer(Peer x) Peer
Subscribe Peer.setState handler peerStateChanged.
createPeerWithSpec(PeerPreference spec) Peer
Peer factory interface.
getPeer([bool wait = true]) Future<Peer>
Get a random throttled Peer or add to reconnect Queue if none and wait.
lostLastPeer() → void
lostLastPeer and peerBecameReady have the only calls to peerChanged.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
peerBecameReady(Peer x) → void
Notify awaitingPeers and peerChanged subscribers of a new Peer.
peerStateChanged(Peer x, PeerState oldState, PeerState newState) → void
Track Peer.setState triggering reconnectPeer or peerChanged.
reconnectPeer() → void
Cycles through connecting in round-robin fashion. Triggers only call to WebSocket.connect this class makes.
removePeer(Peer x) → void
Unsubscribe Peer.stateChanged and Peer.close.
shutdown() → void
Disconnect from and clear peers and connecting. awaitingPeers is unaffected.
toString() String
Returns a string representation of this object.


operator ==(dynamic other) bool
The equality operator. [...]