24 Commits

Author SHA1 Message Date
Adin Schmahmann
7ada018b2a Upgrade DHT version (#479)
* upgraded the protocol id to version 2 (i.e. /kad/2.0.0) and made it so v2 peers running in server mode respond to queries from v1 peers. Note: v2 peers will only send queries using the v2 protocol, will only add v2 peers to their routing tables, and will only tell v1 peers about v2 peers.
* to run a forked network we now use network specific protocol prefixes instead of manually setting protocol IDs. Use the ProtocolPrefix option instead of the Protocols option.
* emit errors during initialization if the user misuses the default protocol prefix by setting parameters inconsistent with the default protocol's network specification
* since the Client option has been deprecated it's been removed from the dht's options. While deprecated it is still available in the dht options package. Setting `Client(false)` now puts the node into ModeAuto.
2020-03-10 16:22:41 -04:00
Steven Allen
d440bbf0c4 feat: move options to main package and make internals private (#486)
* feat: move options to main package and make internals private

Rationale:

1. This allows us to make private options for testing.
2. This removes an import for DHT users.
3. This makes options much easier to discover.
4. This makes it possible to make the config/options internals private.

We originally put them in a sub-package to avoid poluting the root namespace,
but that isn't really necessary.

This keeps the old package (for now) to avoid breaking too much.
2020-03-10 16:21:56 -04:00
Adin Schmahmann
c24a52fc7c
Enable switching DHT between client and server modes (#469)
* created Mode(ModeOpt) option for choosing between auto/client/server modes
* Auto mode internally switches the DHT between client and server modes based on the EvtLocalReachabilityChanged event emitted on the event bus (e.g. by AutoNAT)
* routing table management of peers that switch between client and server mode while we are connected to them (i.e. are in auto mode)
* removed Client(bool) option, becoming a DHT client is specified using Mode(ModeClient) instead
2020-03-06 14:56:03 -05:00
Adin Schmahmann
f94a3f2bd4 options: KValue and AlphaValue global variables no longer used internally. Concurrency option now sets alpha. DisjointPaths option now sets d. Default number of disjoint paths is now bucketSize/2. 2020-03-04 22:11:53 -08:00
Vibhav Pant
766aeee9ed
Add documentation for RoutingTableLatencyTolerance. 2020-02-18 15:21:46 +05:30
Vibhav Pant
04a53d2886
Set defaults for RoutingTable.LatencyTolerance. 2020-02-17 20:12:39 +05:30
Vibhav Pant
fececcc819
Make the Routing Table's latency tolerance configurable. 2020-02-17 20:06:29 +05:30
Steven Allen
5a048eaa57 docs(options): document that DisableValues disables retrieving public keys 2019-12-06 21:44:59 -05:00
Steven Allen
2a39785d3f fix(options): make the disable providers/values options consistent 2019-12-06 09:47:22 -05:00
Steven Allen
c2b72b250d doc(options): document that disabling values/providers should only be done on forked dhts 2019-12-05 19:11:46 -05:00
Steven Allen
52747fc1f0 feat: allow disabling value and provider storage/messages
fixes #274
2019-12-05 19:11:46 -05:00
Aarsh Shah
7a39667d70 make max record age configurable 2019-11-15 10:54:09 +08:00
Raúl Kripalani
a33b0b97a4 inline struct for RoutingTable config. 2019-11-05 23:55:32 +00:00
Steven Allen
ef319676a9 chore: rename bootstrap to refresh
As pointed out by raul, bootstrapping and refreshing are not the same thing.
Bootstrapping is the initial setup (i.e., connect to some initial nodes to get
started). Refreshing is the process of refreshing the routing table.
2019-11-05 23:33:53 +00:00
Steven Allen
ed244cd485 feat(bootstrap): simplify bootstrapping
* Rename triggerAutoBootstrap to autoBootstrap. This variable used to control
_triggering_ only but now completely disables automatic bootstrapping.
* Remove the BootstrapConfig. We introduced this before we switched to
functional options. Now that we're breaking the interfaces anyways, we might as
well use functional options all the way (easier to extend).
* Always query self (feedback from @raulk).
* Important: don't abort the bootstrap process if we timeout finding ourselves.
2019-11-05 22:33:05 +00:00
Aarsh Shah
632f3c5cb5 better handling for disable bootstrap option 2019-11-03 19:57:50 +08:00
Aarsh Shah
7cce5bdd96 make bootstrap synchronous & get tests to work 2019-11-02 00:37:15 +08:00
Aarsh Shah
f4630f62d5 1) seed RT whenever it becomes empty
2) seed RT if empty before starting bootstrap incase 1 hasn't fired
3) pass bootstrap config as option while creating Dht
4) replace all bootstrap function with 1 function
2019-10-11 13:17:36 +09:00
Raúl Kripalani
fed99afe6e
Make routing table bucket size configurable (#396) 2019-10-04 22:12:00 +09:00
Raúl Kripalani
31765355df
migrate to consolidated types. (#344) 2019-05-26 23:33:15 +01:00
Matt Joiner
4804caf13f Remove the old protocol from the defaults 2019-04-15 13:20:48 +10:00
Erin Swenson-Healey
3b148d2b88 make Protocols variadic, for usability 2018-06-01 15:54:53 -07:00
Erin Swenson-Healey
d94deae41d make DHT protocols pluggable 2018-06-01 14:55:16 -07:00
Steven Allen
c0d3351b8d revert interface changes and add options
Instead of changing the existing constructors, add a new DHT constructor that
takes options (and add DHT options).
2018-05-31 17:54:24 -07:00