Skip to content
This repository was archived by the owner on Jul 21, 2023. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: libp2p/js-libp2p-kad-dht
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 088534b3a54f3c172c34000d12812d4b99346fb3
Choose a base ref
...
head repository: libp2p/js-libp2p-kad-dht
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 42eb5ebfb6c5359698af7cec8fcda68411c6115a
Choose a head ref
Loading
Showing with 3,833 additions and 4,373 deletions.
  1. +127 −0 CHANGELOG.md
  2. +4 −4 README.md
  3. +42 −40 package.json
  4. +0 −2 src/constants.js
  5. +281 −0 src/content-fetching/index.js
  6. +158 −0 src/content-routing/index.js
  7. +326 −496 src/index.js
  8. +11 −19 src/message/index.js
  9. +77 −115 src/network.js
  10. +0 −101 src/peer-distance-list.js
  11. +12 −12 src/{peer-list.js → peer-list/index.js}
  12. +5 −5 src/{ → peer-list}/limited-peer-list.js
  13. +88 −0 src/peer-list/peer-distance-list.js
  14. +6 −5 src/{ → peer-list}/peer-queue.js
  15. +274 −0 src/peer-routing/index.js
  16. +0 −605 src/private.js
  17. +5 −6 src/providers.js
  18. +2 −1 src/query/index.js
  19. +2 −3 src/query/path.js
  20. +3 −4 src/query/run.js
  21. +5 −7 src/query/workerQueue.js
  22. +12 −7 src/random-walk.js
  23. +31 −50 src/routing.js
  24. +15 −21 src/rpc/handlers/add-provider.js
  25. +19 −24 src/rpc/handlers/find-node.js
  26. +15 −32 src/rpc/handlers/get-providers.js
  27. +30 −38 src/rpc/handlers/get-value.js
  28. +1 −1 src/rpc/handlers/index.js
  29. +6 −7 src/rpc/handlers/ping.js
  30. +11 −24 src/rpc/handlers/put-value.js
  31. +50 −69 src/rpc/index.js
  32. +22 −37 src/utils.js
  33. +666 −1,061 test/kad-dht.spec.js
  34. +27 −45 test/kad-utils.spec.js
  35. +18 −22 test/limited-peer-list.spec.js
  36. +50 −57 test/message.spec.js
  37. +110 −0 test/multiple-nodes.spec.js
  38. +105 −76 test/network.spec.js
  39. +64 −98 test/peer-distance-list.spec.js
  40. +8 −14 test/peer-list.spec.js
  41. +1 −1 test/peer-queue.spec.js
  42. +29 −30 test/providers.spec.js
  43. +358 −434 test/query.spec.js
  44. +99 −118 test/query/index.spec.js
  45. +40 −12 test/random-walk.spec.js
  46. +43 −88 test/routing.spec.js
  47. +59 −70 test/rpc/handlers/add-provider.spec.js
  48. +29 −54 test/rpc/handlers/find-node.spec.js
  49. +39 −63 test/rpc/handlers/get-providers.spec.js
  50. +51 −87 test/rpc/handlers/get-value.spec.js
  51. +12 −23 test/rpc/handlers/ping.spec.js
  52. +30 −40 test/rpc/handlers/put-value.spec.js
  53. +47 −53 test/rpc/index.spec.js
  54. +20 −34 test/simulation/index.js
  55. +45 −48 test/utils/create-disjoint-tracks.js
  56. +19 −0 test/utils/create-peer-id.js
  57. +0 −19 test/utils/create-peer-info.js
  58. +11 −11 test/utils/create-values.js
  59. +86 −20 test/utils/index.js
  60. +112 −60 test/utils/test-dht.js
  61. +15 −0 test/utils/to-buffer.js
127 changes: 127 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,130 @@
<a name="0.19.0"></a>
# [0.19.0](https://github.com/libp2p/js-libp2p-kad-dht/compare/v0.19.0-pre.0...v0.19.0) (2020-04-24)


### Chores

* peer-discovery not using peer-info ([#180](https://github.com/libp2p/js-libp2p-kad-dht/issues/180)) ([f0fb212](https://github.com/libp2p/js-libp2p-kad-dht/commit/f0fb212))


### BREAKING CHANGES

* peer event emitted with id and multiaddrs properties instead of peer-info



<a name="0.19.0-pre.0"></a>
# [0.19.0-pre.0](https://github.com/libp2p/js-libp2p-kad-dht/compare/v0.18.6...v0.19.0-pre.0) (2020-04-16)


### Chores

* use new peer store api ([#179](https://github.com/libp2p/js-libp2p-kad-dht/issues/179)) ([194c701](https://github.com/libp2p/js-libp2p-kad-dht/commit/194c701))


### BREAKING CHANGES

* uses new peer-store api



<a name="0.18.6"></a>
## [0.18.6](https://github.com/libp2p/js-libp2p-kad-dht/compare/v0.18.5...v0.18.6) (2020-03-26)



<a name="0.18.5"></a>
## [0.18.5](https://github.com/libp2p/js-libp2p-kad-dht/compare/v0.18.4...v0.18.5) (2020-02-14)


### Bug Fixes

* remove use of assert module ([#173](https://github.com/libp2p/js-libp2p-kad-dht/issues/173)) ([de85eb6](https://github.com/libp2p/js-libp2p-kad-dht/commit/de85eb6))



<a name="0.18.4"></a>
## [0.18.4](https://github.com/libp2p/js-libp2p-kad-dht/compare/v0.18.3...v0.18.4) (2020-02-05)



<a name="0.18.3"></a>
## [0.18.3](https://github.com/libp2p/js-libp2p-kad-dht/compare/v0.18.2...v0.18.3) (2019-12-12)


### Bug Fixes

* dont use peer ids in sets ([#165](https://github.com/libp2p/js-libp2p-kad-dht/issues/165)) ([e12e540](https://github.com/libp2p/js-libp2p-kad-dht/commit/e12e540))



<a name="0.18.2"></a>
## [0.18.2](https://github.com/libp2p/js-libp2p-kad-dht/compare/v0.18.1...v0.18.2) (2019-12-06)


### Bug Fixes

* get many should not fail if found locally ([#161](https://github.com/libp2p/js-libp2p-kad-dht/issues/161)) ([091db13](https://github.com/libp2p/js-libp2p-kad-dht/commit/091db13))



<a name="0.18.1"></a>
## [0.18.1](https://github.com/libp2p/js-libp2p-kad-dht/compare/v0.18.0...v0.18.1) (2019-12-05)


### Bug Fixes

* find providers should yield when found locally ([#160](https://github.com/libp2p/js-libp2p-kad-dht/issues/160)) ([e40834a](https://github.com/libp2p/js-libp2p-kad-dht/commit/e40834a))



<a name="0.18.0"></a>
# [0.18.0](https://github.com/libp2p/js-libp2p-kad-dht/compare/v0.17.1...v0.18.0) (2019-11-30)


### Features

* find providers and closest peers return async iterable ([#157](https://github.com/libp2p/js-libp2p-kad-dht/issues/157)) ([f0e6800](https://github.com/libp2p/js-libp2p-kad-dht/commit/f0e6800))


### BREAKING CHANGES

* API for find providers and closest peers return async iterable instead of an array of PeerInfo



<a name="0.17.1"></a>
## [0.17.1](https://github.com/libp2p/js-libp2p-kad-dht/compare/v0.17.0...v0.17.1) (2019-11-28)


### Bug Fixes

* remove extraneous message size filter ([#156](https://github.com/libp2p/js-libp2p-kad-dht/issues/156)) ([58b6b36](https://github.com/libp2p/js-libp2p-kad-dht/commit/58b6b36))



<a name="0.17.0"></a>
# [0.17.0](https://github.com/libp2p/js-libp2p-kad-dht/compare/v0.16.1...v0.17.0) (2019-11-26)


### Bug Fixes

* stop and start should not fail ([#152](https://github.com/libp2p/js-libp2p-kad-dht/issues/152)) ([eee2f61](https://github.com/libp2p/js-libp2p-kad-dht/commit/eee2f61))


### Code Refactoring

* async await ([#148](https://github.com/libp2p/js-libp2p-kad-dht/issues/148)) ([c49fa92](https://github.com/libp2p/js-libp2p-kad-dht/commit/c49fa92))


### BREAKING CHANGES

* Switch to using async/await and async iterators.

Co-Authored-By: Jacob Heun <jacobheun@gmail.com>



<a name="0.16.1"></a>
## [0.16.1](https://github.com/libp2p/js-libp2p-kad-dht/compare/v0.16.0...v0.16.1) (2019-10-21)

8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -50,17 +50,17 @@ The libp2p-kad-dht module offers 3 APIs: Peer Routing, Content Routing and Peer

### Peer Routing

[![](https://raw.githubusercontent.com/libp2p/interface-peer-routing/master/img/badge.png)](https://github.com/libp2p/interface-peer-routing)
[![](https://raw.githubusercontent.com/libp2p/js-libp2p-interfaces/master/src/peer-routing/img/badge.png)](https://github.com/libp2p/js-libp2p-interfaces/tree/master/src/peer-routing)

### Content Routing

[![](https://raw.githubusercontent.com/libp2p/interface-content-routing/master/img/badge.png)](https://github.com/libp2p/interface-content-routing)
[![](https://raw.githubusercontent.com/libp2p/js-libp2p-interfaces/master/src/content-routing/img/badge.png)](https://github.com/libp2p/js-libp2p-interfaces/tree/master/src/content-routing)

### Peer Discovery

[![](https://github.com/libp2p/interface-peer-discovery/raw/master/img/badge.png)](https://github.com/libp2p/interface-peer-discovery)
[![](https://raw.githubusercontent.com/libp2p/js-libp2p-interfaces/master/src/peer-discovery/img/badge.png)](https://github.com/libp2p/js-libp2p-interfaces/tree/master/src/peer-discovery)

`libp2p-kad-dht` provides a discovery service called `Random Walk` (random walks on the DHT to discover more nodes). It is accessible through `dht.randomWalk` and exposes the [Peer Discovery interface](https://github.com/libp2p/interface-peer-discovery).
`libp2p-kad-dht` provides a discovery service called `Random Walk` (random walks on the DHT to discover more nodes). It is accessible through `dht.randomWalk` and exposes the [Peer Discovery interface](https://github.com/libp2p/js-libp2p-interfaces/tree/master/src/peer-discovery).

### Implementation Summary

82 changes: 42 additions & 40 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "libp2p-kad-dht",
"version": "0.16.1",
"version": "0.19.0",
"description": "JavaScript implementation of the Kad-DHT for libp2p",
"leadMaintainer": "Vasco Santos <vasco.santos@moxy.studio>",
"main": "src/index.js",
@@ -32,74 +32,76 @@
"url": "https://github.com/libp2p/js-libp2p-kad-dht/issues"
},
"engines": {
"node": ">=6.0.0",
"npm": ">=3.0.0"
"node": ">=10.0.0",
"npm": ">=6.0.0"
},
"homepage": "https://github.com/libp2p/js-libp2p-kad-dht",
"dependencies": {
"abort-controller": "^3.0.0",
"async": "^2.6.2",
"base32.js": "~0.1.0",
"chai-checkmark": "^1.0.1",
"cids": "~0.7.0",
"cids": "~0.8.0",
"debug": "^4.1.1",
"err-code": "^1.1.2",
"err-code": "^2.0.0",
"hashlru": "^2.3.0",
"heap": "~0.2.6",
"interface-datastore": "~0.7.0",
"interface-datastore": "~0.8.0",
"it-length-prefixed": "^3.0.0",
"it-pipe": "^1.1.0",
"k-bucket": "^5.0.0",
"libp2p-crypto": "~0.16.1",
"libp2p-record": "~0.6.2",
"multihashes": "~0.4.14",
"multihashing-async": "~0.5.2",
"p-queue": "^6.0.0",
"libp2p-crypto": "~0.17.1",
"libp2p-interfaces": "^0.3.0",
"libp2p-record": "~0.7.0",
"multiaddr": "^7.4.3",
"multihashes": "~0.4.15",
"multihashing-async": "~0.8.0",
"p-filter": "^2.1.0",
"p-map": "^4.0.0",
"p-queue": "^6.2.1",
"p-timeout": "^3.2.0",
"p-times": "^2.1.0",
"peer-id": "~0.12.2",
"peer-info": "~0.15.1",
"peer-id": "~0.13.5",
"promise-to-callback": "^1.0.0",
"promisify-es6": "^1.0.3",
"protons": "^1.0.1",
"pull-length-prefixed": "^1.3.2",
"pull-stream": "^3.6.9",
"streaming-iterables": "^4.1.1",
"varint": "^5.0.0",
"xor-distance": "^2.0.0"
},
"devDependencies": {
"aegir": "^20.0.0",
"aegir": "^21.0.2",
"async-iterator-all": "^1.0.0",
"chai": "^4.2.0",
"datastore-level": "~0.12.1",
"chai-checkmark": "^1.0.1",
"datastore-level": "~0.14.1",
"delay": "^4.3.0",
"dirty-chai": "^2.0.1",
"interface-connection": "~0.3.3",
"libp2p-mplex": "~0.8.5",
"libp2p-switch": "~0.42.7",
"libp2p-tcp": "~0.13.0",
"it-pair": "^1.0.0",
"libp2p": "libp2p/js-libp2p#0.28.x",
"lodash": "^4.17.11",
"lodash.random": "^3.2.0",
"lodash.range": "^3.2.0",
"peer-book": "~0.9.1",
"sinon": "^7.3.1"
"p-defer": "^3.0.0",
"p-each-series": "^2.1.0",
"p-map-series": "^2.1.0",
"p-retry": "^4.2.0",
"sinon": "^9.0.0"
},
"contributors": [
"Alan Shaw <alan.shaw@protocol.ai>",
"Blake Byrnes <blakebyrnes@gmail.com>",
"Vasco Santos <vasco.santos@moxy.studio>",
"David Dias <daviddias.p@gmail.com>",
"Friedel Ziegelmayer <dignifiedquire@gmail.com>",
"Hugo Dias <hugomrdias@gmail.com>",
"Hugo Dias <mail@hugodias.me>",
"Jacob Heun <jacobheun@gmail.com>",
"dirkmc <dirkmdev@gmail.com>",
"Alan Shaw <alan.shaw@protocol.ai>",
"Friedel Ziegelmayer <dignifiedquire@gmail.com>",
"Richard Schneider <makaretu@gmail.com>",
"Blake Byrnes <blakebyrnes@gmail.com>",
"John Hiesey <jhiesey@cs.stanford.edu>",
"Hugo Dias <hugomrdias@gmail.com>",
"ᴠɪᴄᴛᴏʀ ʙᴊᴇʟᴋʜᴏʟᴍ <victorbjelkholm@gmail.com>",
"Alex Potsides <alex@achingbrain.net>",
"Lars Gierth <larsg@systemli.org>",
"Marcus Bernales <mboperator@gmail.com>",
"Pedro Teixeira <i@pgte.me>",
"Qmstream <51881352+Qmstream@users.noreply.github.com>",
"Richard Schneider <makaretu@gmail.com>",
"Thomas Eizinger <thomas@eizinger.io>",
"Vasco Santos <vasco.santos@moxy.studio>",
"Vasco Santos <vasco.santos@ua.pt>",
"dirkmc <dirkmdev@gmail.com>",
"dirkmc <dirk@mccormick.cx>",
"kumavis <kumavis@users.noreply.github.com>",
"kumavis <aaron@kumavis.me>",
"ᴠɪᴄᴛᴏʀ ʙᴊᴇʟᴋʜᴏʟᴍ <victorbjelkholm@gmail.com>"
"Thomas Eizinger <thomas@eizinger.io>"
]
}
2 changes: 0 additions & 2 deletions src/constants.js
Original file line number Diff line number Diff line change
@@ -34,8 +34,6 @@ exports.K = 20
// Alpha is the concurrency for asynchronous requests
exports.ALPHA = 3

exports.maxMessageSize = 2 << 22 // 4MB

exports.defaultRandomWalk = {
enabled: true,
queriesPerPeriod: 1,
Loading