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
nodeIdoraddressonaddHint. bestHint()returnsnullwhen no hints stored.
Composition
- Feed
bestHint()into your DHT client bootstrap list. - Complements
hyper-p2p-peer-bootstrap-storepeer-level hints. - Score rises with independent confirming peers (
sourceslength).
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()