Swarm class

Swarm is a Network implementation that manages connections to peers and handles streams over those connections.

Implemented types

Constructors

Swarm.new({required Host? host, required PeerId localPeer, required Peerstore peerstore, required ResourceManager resourceManager, required BasicUpgrader upgrader, required Config config, List<Transport>? transports})
Creates a new Swarm

Properties

conns List<Conn>
Returns the connections in this Network
no setteroverride
hashCode int
The hash code for this object.
no setterinherited
interfaceListenAddresses Future<List<MultiAddr>>
Returns a list of addresses at which this network listens. It expands "any interface" addresses (/ip4/0.0.0.0, /ip6/::) to use the known local interfaces.
no setteroverride
listenAddresses List<MultiAddr>
Returns a list of addresses at which this network listens.
no setteroverride
localPeer PeerId
Returns the local peer associated with this network
no setteroverride
peers List<PeerId>
Returns the peers connected
no setteroverride
peerstore Peerstore
Returns the internal peerstore This is useful to tell the dialer about a new address for a peer. Or use one of the public keys found out over the network.
no setteroverride
resourceManager ResourceManager
Returns the ResourceManager associated with this network
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addTransport(Transport transport) → void
Adds a transport to the swarm
canDial(PeerId peerId, MultiAddr addr) bool
Returns whether the dialer can dial peer p at addr
override
close() Future<void>
Closes the network
override
closePeer(PeerId peerId) Future<void>
Closes the connection to a given peer
override
connectedness(PeerId peerId) Connectedness
Returns a state signaling connection capabilities
override
connsToPeer(PeerId peerId) List<Conn>
Returns the connections in this Network for given peer.
override
dialPeer(Context context, PeerId peerId) Future<Conn>
Establishes a connection to a given peer
override
getListenAddrs() Future<List<MultiAddr>>
listen(List<MultiAddr> addrs) Future<void>
Tells the network to start listening on given multiaddrs.
override
newStream(Context context, PeerId peerId) Future<P2PStream>
Returns a new stream to given peer p. If there is no connection to p, attempts to create one.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notify(Notifiee notifiee) → void
Register a notifiee for signals
override
onConnectionHealthChanged(SwarmConn conn, ConnectionHealthState newState) → void
Event-driven connection health change handler
removeConnection(SwarmConn conn) Future<void>
Removes a connection from the swarm
removeListenAddress(MultiAddr addr) → void
override
setHost(Host host) → dynamic
Sets the host for this swarm. This is used to resolve a circular dependency during initialization.
setStreamHandler(String protocol, Future<void> handler(dynamic stream, PeerId remotePeer)) → void
Sets the handler for new streams opened by the remote side. This operation is thread-safe.
override
stopNotify(Notifiee notifiee) → void
Unregister a notifiee for signals
override
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited