Files
modules/network-transport/hyper-p2p-dht-bootstrap-hint
2026-05-20 23:36:32 -04:00
..
2026-05-20 23:36:32 -04:00
2026-05-20 22:56:32 -04:00
2026-05-20 22:56:32 -04:00
2026-05-20 21:19:52 -04:00
2026-05-20 22:56:32 -04:00
2026-05-20 21:57:50 -04:00
2026-05-20 21:57:50 -04:00
2026-05-20 23:36:32 -04:00

hyper-p2p-dht-bootstrap-hint

Collect and score DHT bootstrap node hints (nodeId + address) via gossip; pick bestHint() by score and recency.

Category: network-transport · Protocol: dht-bootstrap-hint/v1 · Exports: HyperP2PDhtBootstrapHint, PROTOCOL

When to use

Peers share known DHT nodes to improve join success on sparse networks.

When not to use

Hard-coded bootstrap list with no peer contribution.

Quick start

const { HyperP2PDhtBootstrapHint } = require('hyper-p2p-dht-bootstrap-hint')
const hints = new HyperP2PDhtBootstrapHint({ topic: 'dht' })
await hints.ready()
hints.addHint('node-1', '1.2.3.4:6881')
console.log(hints.bestHint())
await hints.close()

Docs

Test

npm test

API

Member Description
new HyperP2PDhtBootstrapHint(opts?) topic, keyPair; peerHex.
addHint(nodeId, address) Increment score, add source, gossip hint-add.
getHints() Serializable array: { nodeId, address, score, lastSeen, sources[] }.
bestHint() Highest score, tie-break lastSeen.
getStats() { added, gossipIn, gossipOut, hints, protocol }.
ready() / close() Swarm lifecycle.

Events: hint (local and { remote: true }), closed.

Architecture

Key = nodeId + NUL + address
_hint Map(key -> { score, lastSeen, sources Set })
Remote merge: score++ only when new source peer; lastSeen = max(at)

Local addHint always bumps score and adds self to sources.

Wire table

type Fields Direction
hint-add nodeId, address, from, at Any → all

Errors

  • Empty nodeId or address on addHint.
  • bestHint() returns null when no hints stored.

Composition

  • Feed bestHint() into your DHT client bootstrap list.
  • Complements hyper-p2p-peer-bootstrap-store peer-level hints.
  • Score rises with independent confirming peers (sources length).

Example

const { HyperP2PDhtBootstrapHint } = require('hyper-p2p-dht-bootstrap-hint')

const hints = new HyperP2PDhtBootstrapHint({ topic: process.argv[2] })
await hints.ready()

hints.addHint('node-1', '1.2.3.4:6881')
console.log(hints.bestHint())
console.log(hints.getHints())
await hints.close()