tuweni / org.apache.tuweni.scuttlebutt.lib / NetworkService

NetworkService

open class NetworkService (source)

A service for operations that connect nodes together and other network related operations

Assumes the standard 'ssb-gossip' plugin is installed and enabled on the node that we're connected to (or that RPC functions meeting its manifest's contract are available.).

Should not be constructed directly, should be used via an ScuttlebuttClient instance.

Functions

createChangesStream

open fun createChangesStream(streamHandler: Function<Runnable, StreamHandler<PeerStateChange>>): Unit

Opens a stream of peer connection state changes.

generateInviteCode

open fun generateInviteCode(validForUses: Int): AsyncResult<Invite>

Generates an invite code which can be used by another node to connect to our node, and have each node will befriend each other.

getAllKnownPeers

open fun getAllKnownPeers(): AsyncResult<MutableList<Peer>>

Queries for all the peers the instance is aware of in its gossip table.

getConnectedPeers

open fun getConnectedPeers(): AsyncResult<MutableList<Peer>>

Queries for the list of peers the instance is connected to.

redeemInviteCode

open fun redeemInviteCode(invite: Invite): AsyncResult<Void>

Redeems an invite issued by another node. If successful, the node will connect to the other node and each node will befriend each other.