tuweni / org.apache.tuweni.devp2p / EphemeralPeerRepository

EphemeralPeerRepository

class EphemeralPeerRepository : PeerRepository (source)

An in-memory peer repository.

Note: as the storage is in-memory, no retrieval methods in this implementation will suspend.

Constructors

<init>

An in-memory peer repository.

EphemeralPeerRepository(peers: MutableMap<PublicKey, Peer> = ConcurrentHashMap())

Functions

addListener

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

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

get

Get a peer from node ID and endpoint information

fun get(nodeId: PublicKey, endpoint: Endpoint): Peer

Get a Peer based on a URI components.

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

Get a Peer based on a URI.

suspend fun get(uri: URI): Peer

getAsync

Get a Peer based on a URI.

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

Get a Peer based on a URI string.

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