Giter VIP home page Giter VIP logo

Comments (2)

feross avatar feross commented on May 11, 2024

For 1), from the readme:

arr = dht.toArray()

Returns the nodes in the DHT as an array. This is useful for persisting the DHT
to disk between restarts of a BitTorrent client (as recommended by the spec). Each node in the array is an object with id (hex string) and addr (string) properties.

To restore the DHT nodes when instantiating a new DHT object, simply pass in the array as the value of the bootstrap option.

var dht1 = new DHT()

// some time passes ...

// destroy the dht
var arr = dht1.toArray()
dht1.destroy()

// some time passes ...

// initialize a new dht with the same routing table as the first
var dht2 = new DHT({ bootstrap: arr })

from bittorrent-dht.

feross avatar feross commented on May 11, 2024

For 2), you can take some of the peers from the tracker and try adding them to the DHT:

dht.addNode(addr, [nodeId])

Manually add a node to the DHT routing table. If there is space in the routing table (or
an unresponsive node can be evicted to make space), the node will be added. If not, the
node will not be added. This is useful to call when a peer wire sends a PORT message to
share their DHT port.

If nodeId is undefined, then the peer will be pinged to learn their node id. If the peer does not respond, the will not be added to the routing table.

However, there's a issue right now where nodeId is actually required, and you obviously won't know that in advance, since "dht node id" is different from "bittorrent peer id". Issue is open here: #26 PR welcome :)

from bittorrent-dht.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.