Commit Graph

1247 Commits

Author SHA1 Message Date
f9a79c5ca8 go fmt + import reordering 2020-03-24 03:16:38 -04:00
a21162d55c make the query logic panic if the state is invalid 2020-03-24 03:16:38 -04:00
de9d5ae745 fix lookup followup goroutine cancellation 2020-03-24 03:16:38 -04:00
8656be1b86 more comments 2020-03-24 03:16:38 -04:00
15e343b8b0 do not mark the routing table as updated after a FindPeer query. bootstrap logic now uses GetClosestPeers instead of FindPeer. FindPeer can return addresses even if not Connected as long as it was either recently connected (CanConnect) or was discovered during the lookup. 2020-03-24 03:16:38 -04:00
11d4d73729 Merge pull request #501 from libp2p/feat/async-tests
Tests for Async Query Logic
2020-03-24 01:05:01 +05:30
6a56205bab tests for qpeerset 2020-03-23 22:16:18 +05:30
c9d93bdaa9 go fmt 2020-03-23 02:15:13 -04:00
b04ec8ab88 move lookup result construction into its own function 2020-03-23 02:15:13 -04:00
9476ad8683 query state transitions bug fixes. fix wrapper function to take into account disjoint paths. Adjust test to take into account new query behavior (i.e. GetClosestPeers is no longer guaranteed to find k peers if the routing tables are invalid, e.g. ring setups) 2020-03-23 02:15:13 -04:00
a4fcc84647 add wrapper lookup function to ensure that the top k returned peers from a lookup have all been queried even for beta < k. Modified the structure returned from lookups to be a useful subset of the full query state. 2020-03-23 02:15:13 -04:00
86fd84adf4 Bug fixes. 2020-03-23 02:15:13 -04:00
f9f08b5f5a Addressing PR comments. Documentation. Naming fixes. 2020-03-23 02:15:13 -04:00
7cf6b8f2e8 fix: use dht.beta instead of 3 for refreshing cpl 2020-03-23 02:15:13 -04:00
1c33021cee fix(test): give find peer query tests stable routing tables 2020-03-23 02:15:13 -04:00
f65f5626b1 fix: simple async query bugs 2020-03-23 02:15:13 -04:00
516cd0b49d refactor(dht): stopFn no longer takes any state. Beta publicly exposed as the Resiliency parameter. 2020-03-23 02:15:13 -04:00
49b07fa585 Fully async implementation of Kademlia lookup. 2020-03-23 02:09:19 -04:00
2dfbbc4693 tmp 2020-03-23 02:09:19 -04:00
8eade909a7 feat: calling FindProvidersAsync with a count of zero now completes the query 2020-03-23 01:59:57 -04:00
147dc1244d cleanup: documentation and code cleanup for search/getvalue quorum defaulting to zero 2020-03-23 01:59:57 -04:00
075afe8528 fix: protect rng with a mutex 2020-03-23 01:59:57 -04:00
42addc4c24 fix(test): increase timeout for notification tests since it's slow on Windows 2020-03-23 01:59:57 -04:00
7c27400a1e Merge pull request #495 from libp2p/feat/fix-tests
Fix test logging & document timing issue on Windows
2020-03-17 13:13:06 -04:00
45c403c1bc document test failure 2020-03-17 22:39:56 +05:30
f4e0b0d25b change tests 2020-03-16 22:11:37 +05:30
e42ee94214 Cypress Disjoint Query & Query Termination code cleanup (#489)
* kpeerset refactoring
* query code cleanup
2020-03-13 15:04:25 -07:00
fbb1b3668a RT connectivity changes 2020-03-10 14:51:28 -07:00
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
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
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
bf4986ec8f made deprecated util values have comments that satisfy golint 2020-03-06 14:38:15 -05:00
376300a6ff fix: actually ignore deadline exceeded errors in Provide (#480) 2020-03-06 00:00:51 -05:00
e50572360e fix: improve context deadline handling
1. Continue to best-effort provide, but still return an error when we fail to
send provider records to the _best_ peers.
2. Continue returning the best peer's we've found in GetClosestPeers, but also
return an error to indicate that we didn't find the closest ones.

And fix the hang test.
2020-03-05 20:01:39 -08:00
5d313b134c Utilize identify events to add peers to the routing table (#472)
* feat: consume identify events to evaluate routing table addition
* fix: routing table no longer gets an update just because new messages have arrived or been sent
* fix: add already connected peers into the routing table before listening to events

Co-authored-by: Raúl Kripalani <raul.kripalani@gmail.com>
Co-authored-by: Aarsh Shah <aarshkshah1992@gmail.com>
2020-03-04 22:26:30 -08:00
8ef9d774c9 cleanup unused code 2020-03-04 22:11:53 -08:00
b4f7fda731 check for stopping the query in between dialing and querying 2020-03-04 22:11:53 -08:00
6b25a6c008 try another peer sorting metric. fix bug in when findproviders returns 2020-03-04 22:11:53 -08:00
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
0ef814afd2 test: switch tests to use dht.bucketSize instead of KValue for queries 2020-03-04 22:11:53 -08:00
79648b84e4 fix: use dht.bucketSize instead of KValue for queries 2020-03-04 22:11:53 -08:00
1984feb89e added todo comment about FindPeer and peer connectedness 2020-03-04 22:11:53 -08:00
c79bac3a7a SearchValue will only update k closest peers to have latest record 2020-03-04 22:11:53 -08:00
6469073a4b query switches from alpha mode to k mode if no peers closer than one we have heard about (in a given path) has been found 2020-03-04 22:11:53 -08:00
719a16ff88 error on queries to empty routing table 2020-03-04 22:11:53 -08:00
a9e21d2672 Search/GetValues stops if using quorum 2020-03-04 22:11:53 -08:00
5cabdf6d13 fix refreshing buckets during query. getting topK peers is more efficient. 2020-03-04 22:11:53 -08:00
68b116932f fix Search/GetValue to be Kad compliant. Default quorum is now 0 which means do not abort the query early 2020-03-04 22:11:53 -08:00
c4e94ce0fe first pass at proper kad 2020-03-04 22:11:53 -08:00
c01366876c upgrade deprecated query events 2020-03-04 22:11:53 -08:00