tuweni / org.apache.tuweni.ethclient / MemoryEthereumPeerRepository

MemoryEthereumPeerRepository

class MemoryEthereumPeerRepository : EthereumPeerRepository (source)

Memory-backed Ethereum peer repository.

Constructors

<init>

Memory-backed Ethereum peer repository.

MemoryEthereumPeerRepository()

Properties

connections

val connections: ConcurrentHashMap<String, EthereumConnection>

identities

val identities: HashSet<Identity>

identityListeners

val identityListeners: HashMap<String, (Identity) -> Unit>

peerMap

val peerMap: ConcurrentHashMap<Identity, Peer>

statusListeners

val statusListeners: HashMap<String, (EthereumConnection) -> Unit>

Functions

activeConnections

Provides a stream of active connections.

fun activeConnections(): Stream<EthereumConnection>

addConnection

fun addConnection(peer: Peer, identity: Identity): Unit

addIdentityListener

Adds a listener to be called when a new peer connects

fun addIdentityListener(identityListener: (Identity) -> Unit): String

addStatusListener

Adds a listener to be called when a status message is received

fun addStatusListener(statusListener: (EthereumConnection) -> Unit): String

markConnectionInactive

fun markConnectionInactive(peer: Peer, identity: Identity): Unit

peerDiscoveredAt

fun peerDiscoveredAt(peer: Peer, time: Long): Unit

randomPeer

fun randomPeer(): Peer?

removeIdentityListener

Removes an identity listener

fun removeIdentityListener(id: String): Unit

removeStatusListener

Removes a status listener

fun removeStatusListener(id: String): Unit

storeIdentity

fun storeIdentity(networkInterface: String, port: Int, publicKey: PublicKey): Identity

storePeer

fun storePeer(id: Identity, lastContacted: Instant?, lastDiscovered: Instant?): Peer

storeStatus

Stores the status message sent for a connection

fun storeStatus(connId: String, status: Status): Unit