tuweni / org.apache.tuweni.devp2p / DiscoveryService

DiscoveryService

interface DiscoveryService (source)

An Ethereum ÐΞVp2p discovery service.

This service supports devp2p discovery v4, alongside support for EIP-868. http://eips.ethereum.org/EIPS/eip-868

Properties

expiredPackets

Counter of expired packets

abstract val expiredPackets: Long

filteredPackets

Counter of filtered packets

abstract val filteredPackets: Long

invalidPackets

Counter of invalid packets

abstract val invalidPackets: Long

isShutdown

true if the service has been shutdown

abstract val isShutdown: Boolean

localPort

the UDP port that the service is listening on

abstract val localPort: Int

nodeId

the node id for this node (i.e. it's public key)

abstract val nodeId: PublicKey

selfPackets

Counter of packets sent to self

abstract val selfPackets: Long

unexpectedENRResponses

Counter of unexpected ENRResponse messages

abstract val unexpectedENRResponses: Long

unexpectedNeighbors

Counter of unexpected NEIGHBORS messages

abstract val unexpectedNeighbors: Long

unexpectedPongs

Counter of unexpected pongs

abstract val unexpectedPongs: Long

unvalidatedPeerPackets

Counter of unvalidated peer packets

abstract val unvalidatedPeerPackets: Long

Functions

awaitBootstrap

Suspend until the bootstrap peers have been reached, or failed.

abstract suspend fun awaitBootstrap(): Unit

awaitBootstrapAsync

Suspend until the bootstrap peers have been reached, or failed.

abstract fun awaitBootstrapAsync(): AsyncCompletion

lookup

Attempt to find a specific peer, or peers close to it.

abstract suspend fun lookup(target: PublicKey): List<Peer>

lookupAsync

Attempt to find a specific peer, or peers close to it asynchronously.

abstract fun lookupAsync(target: PublicKey): AsyncResult<List<Peer>>

shutdown

Shuts down this service.

abstract suspend fun shutdown(): Unit

shutdownAsync

Suspend until this service has terminated.

abstract fun shutdownAsync(): AsyncCompletion

Companion Object Functions

open

Start the discovery service.

fun open(vertx: Vertx, keyPair: KeyPair, port: Int = 0, host: String? = null, seq: Long = Instant.now().toEpochMilli(), enrData: Map<String, Bytes> = emptyMap(), bootstrapURIs: List<URI> = emptyList(), peerRepository: PeerRepository = EphemeralPeerRepository(), advertiseAddress: String? = null, advertiseUdpPort: Int? = null, advertiseTcpPort: Int? = null, routingTable: PeerRoutingTable = DevP2PPeerRoutingTable(keyPair.publicKey()), packetFilter: ((PublicKey, SocketAddress) -> Boolean)? = null, timeSupplier: () -> Long = CURRENT_TIME_SUPPLIER): DiscoveryService
fun open(vertx: Vertx, keyPair: KeyPair, bindAddress: SocketAddress, seq: Long = Instant.now().toEpochMilli(), enrData: Map<String, Bytes> = emptyMap(), bootstrapURIs: List<URI> = emptyList(), peerRepository: PeerRepository = EphemeralPeerRepository(), advertiseAddress: String? = null, advertiseUdpPort: Int? = null, advertiseTcpPort: Int? = null, routingTable: PeerRoutingTable = DevP2PPeerRoutingTable(keyPair.publicKey()), packetFilter: ((PublicKey, SocketAddress) -> Boolean)? = null, timeSupplier: () -> Long = CURRENT_TIME_SUPPLIER): DiscoveryService