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

abstract val expiredPackets: Long

filteredPackets

abstract val filteredPackets: Long

invalidPackets

abstract val invalidPackets: Long

isShutdown

abstract val isShutdown: Boolean

true if the service has been shutdown

isTerminated

abstract val isTerminated: Boolean

true if the service has terminated

localPort

abstract val localPort: Int

the UDP port that the service is listening on

nodeId

abstract val nodeId: PublicKey

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

selfPackets

abstract val selfPackets: Long

unexpectedENRResponses

abstract val unexpectedENRResponses: Long

unexpectedNeighbors

abstract val unexpectedNeighbors: Long

unexpectedPongs

abstract val unexpectedPongs: Long

unvalidatedPeerPackets

abstract val unvalidatedPeerPackets: Long

Functions

awaitBootstrap

abstract suspend fun awaitBootstrap(): Int

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

awaitTermination

abstract suspend fun awaitTermination(): Unit

Suspend until this service has terminated.

awaitTerminationAsync

abstract fun awaitTerminationAsync(): AsyncCompletion

Provide a completion that will complete when the service has terminated.

lookup

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

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

lookupAsync

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

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

shutdown

abstract fun shutdown(): Unit

Request shutdown of this service. The service will terminate at a later time (see DiscoveryService.awaitTermination).

shutdownNow

abstract fun shutdownNow(): Unit

Shutdown this service immediately.

Companion Object Functions

open

fun open(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: InetAddress? = null, advertiseUdpPort: Int? = null, advertiseTcpPort: Int? = null, routingTable: PeerRoutingTable = DevP2PPeerRoutingTable(keyPair.publicKey()), packetFilter: (PublicKey, InetSocketAddress) -> Boolean = null, loggerProvider: LoggerProvider = LoggerProvider.nullProvider(), channelGroup: CoroutineChannelGroup = CommonCoroutineGroup, bufferAllocator: () -> ByteBuffer = DEFAULT_BUFFER_ALLOCATOR, timeSupplier: () -> Long = CURRENT_TIME_SUPPLIER): DiscoveryService
fun open(keyPair: KeyPair, bindAddress: InetSocketAddress, seq: Long = Instant.now().toEpochMilli(), enrData: Map<String, Bytes> = emptyMap(), bootstrapURIs: List<URI> = emptyList(), peerRepository: PeerRepository = EphemeralPeerRepository(), advertiseAddress: InetAddress? = null, advertiseUdpPort: Int? = null, advertiseTcpPort: Int? = null, routingTable: PeerRoutingTable = DevP2PPeerRoutingTable(keyPair.publicKey()), packetFilter: (PublicKey, InetSocketAddress) -> Boolean = null, loggerProvider: LoggerProvider = LoggerProvider.nullProvider(), channelGroup: CoroutineChannelGroup = CommonCoroutineGroup, bufferAllocator: () -> ByteBuffer = DEFAULT_BUFFER_ALLOCATOR, timeSupplier: () -> Long = CURRENT_TIME_SUPPLIER): DiscoveryService

Start the discovery service.