PeerManager class
High-level peer manager implementing PeerManagerI
- Implemented types
- Available extensions
Constructors
- PeerManager({required BitcoinNetwork network, PeerHandlerI? handler, PeerManagerConfig? config, Logger? logger, ChainTipTracker? chainTipTracker})
Properties
- chainTipTracker → ChainTipTracker
-
Chain tip tracker for SPV clients
no setter
- config → PeerManagerConfig
-
final
- handler → PeerHandlerI?
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- healthyPeerCount → int
-
Number of healthy peers
no setter
- isShutdown → bool
-
Whether manager is shutdown
no setter
- logger → Logger
-
final
-
messageStream
→ Stream<
WireMessage> -
no setter
- network → BitcoinNetwork
-
Current network
no setter
-
peerAdded
→ Stream<
Peer> -
Event streams
no setter
- peerCount → int
-
Number of connected peers
no setter
-
peerRemoved
→ Stream<
Peer> -
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
addPeer(
PeerI peerInterface) → Future< void> -
Add a peer to the manager
Throws PeerNetworkMismatchException if peer network doesn't match
override
-
addPeerByAddress(
String address, int port, {PeerConfig? peerConfig, PeerHandlerI? handler}) → Future< Peer> - Add peer by address and port
-
addPeersByAddresses(
List< String> addresses, int port, {PeerConfig? peerConfig, PeerHandlerI? handler}) → Future<List< Peer> > -
Available on PeerManager, provided by the PeerManagerExtensions extension
Add multiple peers by address list -
announceBlock(
Hash blockHash, List< PeerI> targetPeers) → Future<List< PeerI> > -
Announce a block hash to specified peers
Returns list of peers that successfully received the announcement
override
-
announceTransaction(
Hash txHash, List< PeerI> targetPeers) → Future<List< PeerI> > -
Announce a transaction hash to specified peers
Returns list of peers that successfully received the announcement
override
-
broadcastMessage(
WireMessage message) → Future< List< Peer> > - Broadcast a message to all healthy peers
-
getHealthyPeers(
) → List< Peer> - Get healthy peers only
-
getPeers(
) → List< PeerI> -
Get all currently managed peers
override
-
getReadyPeers(
) → List< Peer> - Get ready peers (handshake complete)
-
getStatistics(
) → Map< String, dynamic> - Get peer manager statistics
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
removeAllPeers(
) → Future< void> -
Available on PeerManager, provided by the PeerManagerExtensions extension
Remove all peers -
removePeer(
String peerId) → Future< void> - Remove a peer
-
requestBlock(
Hash blockHash) → Future< PeerI?> -
Request a block from the best available peer
Returns the peer handling the request, or null if no peers available
override
-
requestTransaction(
Hash txHash) → Future< PeerI?> -
Request a transaction from the best available peer
Returns the peer handling the request, or null if no peers available
override
-
shutdown(
) → Future< void> -
Shutdown the peer manager and all associated peers
override
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited