This package has been deprecated

Author message:

use node-devp2p-dpt instead

ethereumjs-dht

0.0.8 • Public • Published

SYNOPSIS Build Status

An node.js implementation of ethereum's DHT.

EXAMPLE

For a basic example see example/dht

API

DHT

new DHT(options)

Create a New DHT with the following options -options

  • secretKey - a 32 byte Buffer from which the pubic key is derived
  • timeout - an Interger specifing the wait period in milliseconds to wait for peers to respond
  • port - the port external port that this peer is listening to. If not specifed the port that is used in bound will be used
  • address - the external address that this peer is listening to. if not specifed the port that is used in bound will be used

DHT methods

dht.bind(port, address, [cb])

Binds the port

  • port
  • address
  • cb the callback

dht.close([cb])

Unbinds the port

dht.bootstrap(introPeers, [cb])

Bootstraps the DHT given an array of peers to connect to.

  • introPeers - an Array of peers to try to connect to. They should be objects in following format.
{
  address: String
  port: Number
}

dht.refresh()

Refreshes the nodes and searches for new nodes

DHT events

The DHT object inherits from Events.EventEmitter and emits the following events.

  • ping - Fires when receiving a Ping. Provides a parsed ping packets and the peer it came from
  • pong - Fires when receiving a pong. Provides a parsed ping packets and the peer it came from
  • findNode - Fires when receiving a findNode. Provides a parsed ping packets and the peer it came from
  • neighbors- Fires when receiving a neighbors. Provides a parsed ping packets and the peer it came from
  • error - Provides and error message

CONTRIBUTIONS

Patches welcome! Contributors are listed in the package.json file. Please run the tests before opening a pull request and make sure that you are passing all of them.

If you would like to contribute, but don't know what to work on, check the issues list or ask on the forms or on IRC.

BUGS

When you find issues, please report them:

You can also look for null_radix in #ethereum-dev on irc://irc.freenode.net.

LISCENCE

GPL3

Readme

Keywords

none

Package Sidebar

Install

npm i ethereumjs-dht

Weekly Downloads

3

Version

0.0.8

License

GPL

Last publish

Collaborators

  • null_radix