kademlia-routing-table 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/test-node.yml +23 -0
- package/README.md +0 -2
- package/index.js +2 -2
- package/package.json +7 -7
- package/test.js +3 -4
- package/.travis.yml +0 -4
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
name: Build Status
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches:
|
|
5
|
+
- master
|
|
6
|
+
pull_request:
|
|
7
|
+
branches:
|
|
8
|
+
- master
|
|
9
|
+
jobs:
|
|
10
|
+
build:
|
|
11
|
+
strategy:
|
|
12
|
+
matrix:
|
|
13
|
+
node-version: [lts/*]
|
|
14
|
+
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
15
|
+
runs-on: ${{ matrix.os }}
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v3
|
|
18
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
19
|
+
uses: actions/setup-node@v3
|
|
20
|
+
with:
|
|
21
|
+
node-version: ${{ matrix.node-version }}
|
|
22
|
+
- run: npm install
|
|
23
|
+
- run: npm test
|
package/README.md
CHANGED
|
@@ -6,8 +6,6 @@ XOR distance based routing table used for P2P networks such as a Kademlia DHT.
|
|
|
6
6
|
npm install kademlia-routing-table
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
[](https://travis-ci.org/mafintosh/kademlia-routing-table)
|
|
10
|
-
|
|
11
9
|
Similar to k-buckets, but implemented using the simplifications described in https://github.com/ethereum/wiki/wiki/Kademlia-Peer-Selection
|
|
12
10
|
|
|
13
11
|
To understand the concept behind peer routing, DHTs, and the terms used here,
|
package/index.js
CHANGED
|
@@ -8,7 +8,7 @@ module.exports = class RoutingTable extends EventEmitter {
|
|
|
8
8
|
|
|
9
9
|
this.id = id
|
|
10
10
|
this.k = opts.k || 20
|
|
11
|
-
this.rows = new Array(id.length * 8
|
|
11
|
+
this.rows = new Array(id.length * 8)
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
add (node) {
|
|
@@ -114,7 +114,7 @@ class Row extends EventEmitter {
|
|
|
114
114
|
|
|
115
115
|
if (c === 0) {
|
|
116
116
|
this.nodes[m] = node
|
|
117
|
-
return
|
|
117
|
+
return true
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
if (c < 0) r = m - 1
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kademlia-routing-table",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "XOR based routing table used for P2P networks such as a Kademlia DHT.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"dependencies": {},
|
|
7
7
|
"devDependencies": {
|
|
8
|
-
"standard": "^
|
|
9
|
-
"
|
|
8
|
+
"standard": "^17.1.0",
|
|
9
|
+
"brittle": "^3.3.2"
|
|
10
10
|
},
|
|
11
11
|
"scripts": {
|
|
12
|
-
"test": "standard &&
|
|
12
|
+
"test": "standard && brittle test.js"
|
|
13
13
|
},
|
|
14
14
|
"keywords": [
|
|
15
15
|
"kademlia",
|
|
@@ -23,12 +23,12 @@
|
|
|
23
23
|
],
|
|
24
24
|
"repository": {
|
|
25
25
|
"type": "git",
|
|
26
|
-
"url": "https://github.com/mafintosh/
|
|
26
|
+
"url": "https://github.com/mafintosh/kademlia-routing-table.git"
|
|
27
27
|
},
|
|
28
28
|
"author": "Mathias Buus (@mafintosh)",
|
|
29
29
|
"license": "MIT",
|
|
30
30
|
"bugs": {
|
|
31
|
-
"url": "https://github.com/mafintosh/
|
|
31
|
+
"url": "https://github.com/mafintosh/kademlia-routing-table/issues"
|
|
32
32
|
},
|
|
33
|
-
"homepage": "https://github.com/mafintosh/
|
|
33
|
+
"homepage": "https://github.com/mafintosh/kademlia-routing-table"
|
|
34
34
|
}
|
package/test.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
const
|
|
1
|
+
const test = require('brittle')
|
|
2
2
|
const { randomBytes } = require('crypto')
|
|
3
3
|
const RoutingTable = require('./')
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
test('basic', function (assert) {
|
|
6
6
|
const table = new RoutingTable(id())
|
|
7
7
|
const node = { id: id() }
|
|
8
8
|
|
|
9
9
|
assert.ok(table.add(node))
|
|
10
|
-
assert.
|
|
11
|
-
assert.end()
|
|
10
|
+
assert.alike(table.closest(id()), [node])
|
|
12
11
|
})
|
|
13
12
|
|
|
14
13
|
function id () {
|
package/.travis.yml
DELETED