dht-size-up

2.0.0 • Public • Published

dht-size-up

Estimate the size of a DHT using find_node queries.

npm install dht-size-up

Usage

const size = require('dht-size-up')
const dht = require('dht-rpc')

var bootstrap = dht({ ephemeral: true })
bootstrap.listen(10001)

createNodes(1000)

function createNodes (n) {
  dht({ bootstrap: ['localhost:10001'] })
    .on('ready', function () {
      if (n === 0) return size(bootstrap, console.log)
      return createNodes(--n)
    })
}

API

size(dht, [n = 1000], cb)

Returns an estimate of the size of the DHT or an error to the callback cb. dht should be node capable of performing _find_node queries to the network. n is the number of trials to perform, default is 1000.

License

MIT

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 2.0.0
    1
    • latest

Version History

Package Sidebar

Install

npm i dht-size-up

Weekly Downloads

22

Version

2.0.0

License

MIT

Unpacked Size

5.26 kB

Total Files

5

Last publish

Collaborators

  • chm-diederichs