tuweni / org.apache.tuweni.kademlia / KademliaRoutingTable

KademliaRoutingTable

class KademliaRoutingTable<T> : Set<T> (source)

A Kademlia Routing Table

Constructors

<init>

KademliaRoutingTable(selfId: ByteArray, k: Int, maxReplacements: Int = k, nodeId: (T) -> ByteArray)

Create a new routing table.

Properties

size

val size: Int

Functions

add

fun add(node: T): T?

Add a node to the table.

clear

fun clear(): Unit

Clear all nodes (and replacements) from the table.

contains

fun contains(element: T): Boolean

containsAll

fun containsAll(elements: Collection<T>): Boolean

evict

fun evict(node: T): Boolean

Remove a node from the table, potentially adding an alternative from the replacement cache.

isEmpty

fun isEmpty(): Boolean

iterator

fun iterator(): Iterator<T>

nearest

fun nearest(targetId: ByteArray, limit: Int): List<T>

Return the nearest nodes to a target id, in order from closest to furthest.

Companion Object Functions

create

fun <T> create(selfId: ByteArray, k: Int, nodeId: Function<T, ByteArray>): KademliaRoutingTable<T>
fun <T> create(selfId: ByteArray, k: Int, maxReplacements: Int, nodeId: Function<T, ByteArray>): KademliaRoutingTable<T>

Create a new routing table.