Readonly
[initProtected
dbProtected
keyProtected
loggerReadonly
nodeReadonly
nodeMax number of nodeContactAddresses for each node.
Protected
nodeBuckets stores lexi(NodeBucketIndex)/NodeId/nodeContactAddress
-> NodeContactAddressData
.
nodeContactAddress are canoncialized to be consistent.
Protected
nodeLast updated stores
lexi(NodeBucketIndex)/"time"/lexi(connectedTime)/nodeId
-> nodeId
.
lexi(NodeBucketIndex)/"nodeId"/nodeId
-> lexi(connectedTime)
.
Protected
nodeProtected
nodeMeta stores the keyof NodeBucketMeta
-> NodeBucketMeta[keyof NodeBucketMeta]
.
Readonly
nodeBit size of the node IDs. This is also the total number of buckets.
Protected
spaceDerive the bucket index of the k-buckets from the new NodeId
The bucket key is the string encoded version of bucket index
that preserves lexicographic order
Protected
delDeletes the connectedTime
for a NodeId
Gets a bucket.
The bucket's node IDs is sorted lexicographically by default Alternatively you can acquire them sorted by connected timestamp or by distance to the own NodeId.
Optional
sort: "nodeId" | "connected" | "distance"Optional
order: "asc" | "desc"Optional
limit: numberLimit the number of nodes returned, note that -1
means
no limit, but Infinity
means 0
.
Optional
tran: DBTransactionOptional
ctx: Partial<ContextTimedInput>Get a bucket meta POJO. This will provide default values for missing properties.
Optional
tran: DBTransactionGet a single bucket meta property. This will provide default values for missing properties.
Optional
tran: DBTransactionGets all buckets.
Buckets are always sorted by NodeBucketIndex
first
Then secondly by the sort
parameter
The order
parameter applies to both, for example possible sorts:
NodeBucketIndex asc, NodeID asc
NodeBucketIndex desc, NodeId desc
NodeBucketIndex asc, distance asc
NodeBucketIndex desc, distance desc
NodeBucketIndex asc, connected asc
NodeBucketIndex desc, connected desc
Optional
tran: DBTransactionGets the closest nodes (closest based on Kademlia XOR operator) to a given node ID. The returned results will be sorted by distance in ascending order. If the given node ID already exists in the node graph, then it will be the first result.
Optional
limit: numberDefaults to the bucket limit.
Optional
tran: DBTransactionOptional
ctx: Partial<ContextTimedInput>The NodeBucket
which could have less than limit
nodes if the
node graph has less than the requested limit.
Gets the connectedTime
for a node
Optional
tran: DBTransactionGet a single NodeContact
Optional
tran: DBTransactionOptional
ctx: Partial<ContextTimedInput>Get a single NodeContactAddressData
.
Optional
tran: DBTransactionGet all NodeContact
.
Results are sorted by NodeBucketIndex
then NodeId
then
NodeContactAddress
.
The order
parameter applies to both, for example:
NodeBucketIndex asc, NodeID asc, NodeContactAddress asc
NodeBucketIndex desc, NodeId desc, NodeContactAddress desc
Optional
tran: DBTransactionProtected
purgeThis utility will clean out the oldest addresses until a set amount remain
Optional
tran: DBTransactionProtected
setSets a single bucket meta property. Bucket meta properties cannot be mutated outside.
Protected
setSets the connectedTime
for a NodeId, replaces the old value if it exists
Sets a single NodeContact
for a NodeId
.
This replaces the entire NodeContact
for the NodeId
.
This will increment the bucket count if it is a new NodeID
.
Optional
tran: DBTransactionIf the bucket is full.
Sets a single NodeContactAddressData
for a NodeId
.
This will increment the bucket count if it is a new NodeID
.
Optional
tran: DBTransactionIf the bucket is full.
Protected
setupSets up the space key
The space string is suffixed to the buckets
and meta
sublevels
This is used to allow swapping of sublevels when remapping buckets
during this.resetBuckets
Unsets a NodeId
record.
It will decrement the bucket count if it existed.
Optional
tran: DBTransactionOptional
tran: DBTransactionStatic
createOptional
fresh?: booleanOptional
logger?: LoggerOptional
nodeOptional
nodeOptional
nodeGenerated using TypeDoc
Max number of nodes in each bucket.