Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upPersist DHT nodes #1431
Persist DHT nodes #1431
Conversation
Persists DHT nodes to disk every 15 minutes. Loads persisted nodes on construction. Enabled by default. Default save file is dht.json, under crossplatform app data folder provided by app-data-folder. Adds option dhtState to configure: * false disables * true enables with default path * String specifies path to custom save file
This comment has been minimized.
This comment has been minimized.
welcome
bot
commented
Jul 14, 2018
This comment has been minimized.
This comment has been minimized.
|
Hi guys. Aiming to implement #72 here, persisting DHT nodes. All local tests succeed. It uses app-data-folder to get a good crossplatform default location for variable app data. Loading is unfortunately synchronous. Making the DHT initialization async breaks the client for some reason unclear to me. Usage expects to call methods immediately, but they start failing if DHT loading is not finished. Even with that ready event delayed until everything is ready. If there's an easy way to fix that I can update. |
This comment has been minimized.
This comment has been minimized.
|
I'm proposing a new option |
This comment has been minimized.
This comment has been minimized.
|
I like this, but we need some tests. Would you add them? |
Increases cleanliness of index.js.
Uses loopback for the test DHT server, a local address provided by the network-address module for the client. This is the pattern used in other tests.
Saved node data and the bootstrap list use different formats. Converts to the bootstrap format.
Prior logic disabled DHT state load with any bootstrap value, including a false to disable. Changes to allowing DHT state load if bootstrap is explicitly disabled with a falsy value.
This comment has been minimized.
This comment has been minimized.
|
Thanks for looking it over. I've added 2 tests, 1 for saving, 1 for loading. They're in Started splitting things out into I added an API method |
| @@ -19,6 +20,7 @@ var randombytes = require('randombytes') | |||
| var speedometer = require('speedometer') | |||
| var zeroFill = require('zero-fill') | |||
|
|
|||
| var dhtPersist = require('./lib/dhtpersist') // browser exclude | |||
This comment has been minimized.
This comment has been minimized.
KayleePop
Aug 3, 2018
Contributor
It says browser exclude, but it's not actually excluded in the browser field of package.json?
like this
"browser": {
"./lib/dhtpersist": false
}
This comment has been minimized.
This comment has been minimized.
bookmoons
Aug 6, 2018
Author
Misunderstood what that was about. I was thinking it was some control message to the bundler. I've updated.
| peerId: String|Buffer, // Wire protocol peer ID (default=randomly generated) | ||
| tracker: Boolean|Object, // Enable trackers (default=true), or options object for Tracker | ||
| dht: Boolean|Object, // Enable DHT (default=true), or options object for DHT | ||
| dhtState: Boolean|String, // Persist DHT nodes (default=true), or save file path |
This comment has been minimized.
This comment has been minimized.
KayleePop
Aug 3, 2018
Contributor
I think this would be clearer as two separate variables. A boolean for whether to persist the state, and a file path for persisting the state
Maybe named (doesn't matter)
{
persistDht: Boolean,
persistDhtPath: String
}
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Thanks for the review. Didn't even show up in my activity list. Will have to find a better way to watch for that. I've addressed both of them. |
This comment has been minimized.
This comment has been minimized.
|
I guess one of the automated builds failed. It looks like it failed on |
This comment has been minimized.
This comment has been minimized.
|
I don't like 3 new dependencies, any way these could be integrated as libs? Also, should we enable this by default? @feross ? |
This comment has been minimized.
This comment has been minimized.
I'm dug into something else for a while here, but will look at this when I have a chance. |
This comment has been minimized.
This comment has been minimized.
stale
bot
commented
Nov 25, 2018
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |

bookmoons commentedJul 14, 2018
•
edited
Persists DHT nodes to disk every 15 minutes.
Loads persisted nodes on construction.
Enabled by default.
Default save file is
dht.json, under crossplatform app data folder provided byapp-data-folder.Adds option
dhtStateto configure:Closes #72.