tuweni / org.apache.tuweni.devp2p / PeerRepository

PeerRepository

interface PeerRepository (source)

A repository of peers in an Ethereum network.

Conceptually, this repository stores information about all peers in an Ethereum network, hence the retrieval methods always return a valid Peer. However, the Peer objects are only generated on demand and may be purged from underlying storage if they can be recreated easily.

Functions

addListener

Adds a listener to the repository, which will consume peer entries whenever they are added to the repository.

abstract fun addListener(listener: (Peer) -> Unit): Unit

get

Get a Peer based on a URI components.

abstract suspend fun get(host: String, port: Int, nodeId: PublicKey): Peer

Get a Peer based on a URI.

abstract suspend fun get(uri: URI): Peer

Get a Peer based on a URI string.

open suspend fun get(uri: String): Peer

getAsync

Get a Peer based on a URI.

abstract fun getAsync(uri: URI): AsyncResult<Peer>

Get a Peer based on a URI string.

abstract fun getAsync(uri: String): AsyncResult<Peer>

Inheritors

DiscoveryPeerRepository

class DiscoveryPeerRepository : PeerRepository

EphemeralPeerRepository

An in-memory peer repository.

class EphemeralPeerRepository : PeerRepository

RelationalPeerRepository

open class RelationalPeerRepository : CoroutineScope, PeerRepository