class DefaultUdpConnector : UdpConnector, CoroutineScope
(source)
DefaultUdpConnector(bindAddress: InetSocketAddress, keyPair: KeyPair, selfEnr: Bytes, enrStorage: ENRStorage = DefaultENRStorage(), receiveChannel: CoroutineDatagramChannel = CoroutineDatagramChannel.open(), nodesTable: RoutingTable = RoutingTable(selfEnr), topicTable: TopicTable = TopicTable(), ticketHolder: TicketHolder = TicketHolder(), authenticationProvider: AuthenticationProvider = DefaultAuthenticationProvider(keyPair, nodesTable), packetCodec: PacketCodec = DefaultPacketCodec(keyPair, nodesTable), selfNodeRecord: EthereumNodeRecord = EthereumNodeRecord.fromRLP(selfEnr), messageListeners: MutableList<MessageObserver> = mutableListOf(), coroutineContext: CoroutineContext = Dispatchers.IO) |
val coroutineContext: CoroutineContext |
fun attachObserver(observer: MessageObserver): Unit
Attach observer for listening processed messages |
|
fun detachObserver(observer: MessageObserver): Unit
Remove observer for listening processed message |
|
fun getAwaitingPongRecord(nodeId: Bytes): Bytes?
Retrieve enr of pinging node |
|
fun getEnr(): EthereumNodeRecord
Provides node's ENR |
|
fun getEnrBytes(): Bytes
Provides node's ENR in RLP encoded representation |
|
fun getNodeKeyPair(): KeyPair
Provides node's key pair |
|
fun getNodeRecords(): ENRStorage
Provides enr storage of known nodes |
|
fun getNodesTable(): RoutingTable
Get kademlia routing table |
|
fun getPendingMessage(authTag: Bytes): TrackingMessage?
Retrieve last sent message, in case if it unauthorized and node can resend with authentication header |
|
fun getSessionInitiatorKey(nodeId: Bytes): Bytes
Provides node's session initiator key |
|
fun getTicketHolder(): TicketHolder
Provides node's ticket holder |
|
fun getTopicRegistrar(): TopicRegistrar
Provides node's topic registrar |
|
fun getTopicTable(): TopicTable
Provides node's topic table |
|
suspend fun send(address: InetSocketAddress, message: UdpMessage, destNodeId: Bytes, handshakeParams: HandshakeInitParameters?): Unit
Sends udp message by socket address |
|
suspend fun start(): Unit
Bootstraps receive loop for incoming message handling |
|
fun started(): Boolean
Gives information about connector, whether receive loop is working |
|
suspend fun terminate(): Unit
Shut downs both udp receive loop and sender socket |
fun CoroutineScope.asyncCompletion(context: CoroutineContext = Dispatchers.Default, start: CoroutineStart = CoroutineStart.DEFAULT, block: suspend CoroutineScope.() -> Unit): AsyncCompletion
Starts new co-routine and returns its result as an implementation of AsyncCompletion. The running co-routine is cancelled when the resulting future is cancelled or otherwise completed. |
|
fun <T> CoroutineScope.asyncResult(context: CoroutineContext = Dispatchers.Default, start: CoroutineStart = CoroutineStart.DEFAULT, block: suspend CoroutineScope.() -> T): AsyncResult<T>
Starts new co-routine and returns its result as an implementation of AsyncResult. The running co-outine is cancelled when the resulting future is cancelled or otherwise completed. |
|
suspend fun <R> CoroutineScope.retry(retryDelay: Long, block: suspend (Int) -> R?): R suspend fun <R> CoroutineScope.retry(retryDelay: Long, maxRetries: Int, block: suspend (Int) -> R?): R? suspend fun <R> CoroutineScope.retry(retryDelay: (Int) -> Long?, block: suspend (Int) -> R?): R?
Retry a suspending block until a non-null result is obtained. |