@libp2p/kad-dht 14.0.0 → 14.0.1
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/dist/index.min.js +2 -2
- package/dist/src/constants.d.ts +1 -0
- package/dist/src/constants.d.ts.map +1 -1
- package/dist/src/constants.js +3 -0
- package/dist/src/constants.js.map +1 -1
- package/dist/src/routing-table/closest-peers.js +3 -3
- package/dist/src/routing-table/closest-peers.js.map +1 -1
- package/package.json +10 -10
- package/src/constants.ts +5 -0
- package/src/routing-table/closest-peers.ts +3 -3
package/dist/src/constants.d.ts
CHANGED
|
@@ -18,4 +18,5 @@ export declare const QUERY_SELF_TIMEOUT: number;
|
|
|
18
18
|
export declare const TABLE_REFRESH_INTERVAL: number;
|
|
19
19
|
export declare const TABLE_REFRESH_QUERY_TIMEOUT: number;
|
|
20
20
|
export declare const DEFAULT_QUERY_TIMEOUT: number;
|
|
21
|
+
export declare const KEEP_ALIVE_TAG = "keep-alive-kad-dht";
|
|
21
22
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,MAAM,OAAO,CAAA;AAC1B,eAAO,MAAM,MAAM,QAAc,CAAA;AACjC,eAAO,MAAM,IAAI,QAAc,CAAA;AAE/B,eAAO,MAAM,cAAc,QAAY,CAAA;AAEvC,eAAO,MAAM,QAAQ,oBAAoB,CAAA;AAEzC,eAAO,MAAM,iBAAiB,gBAAgB,CAAA;AAE9C,eAAO,MAAM,mBAAmB,kBAAkB,CAAA;AAElD,eAAO,MAAM,wBAAwB,MAAM,CAAA;AAE3C,eAAO,MAAM,kBAAkB,QAAY,CAAA;AAE3C,eAAO,MAAM,0BAA0B,QAAO,CAAA;AAE9C,eAAO,MAAM,oBAAoB,QAAc,CAAA;AAG/C,eAAO,MAAM,qBAAqB,KAAK,CAAA;AAGvC,eAAO,MAAM,CAAC,KAAK,CAAA;AAGnB,eAAO,MAAM,KAAK,IAAI,CAAA;AAGtB,eAAO,MAAM,mBAAmB,QAAa,CAAA;AAG7C,eAAO,MAAM,2BAA2B,OAAS,CAAA;AAGjD,eAAO,MAAM,kBAAkB,QAAa,CAAA;AAG5C,eAAO,MAAM,sBAAsB,QAAa,CAAA;AAGhD,eAAO,MAAM,2BAA2B,QAAc,CAAA;AAGtD,eAAO,MAAM,qBAAqB,QAAe,CAAA;AAGjD,eAAO,MAAM,cAAc,uBAA0B,CAAA"}
|
package/dist/src/constants.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// For example, a record may contain an ipns entry with an EOL saying its valid
|
|
5
5
|
// until the year 2020 (a great time in the future). For that record to stick around
|
|
6
6
|
// it must be rebroadcasted more frequently than once every 'MaxRecordAge'
|
|
7
|
+
import { KEEP_ALIVE } from '@libp2p/interface';
|
|
7
8
|
export const second = 1000;
|
|
8
9
|
export const minute = 60 * second;
|
|
9
10
|
export const hour = 60 * minute;
|
|
@@ -33,4 +34,6 @@ export const TABLE_REFRESH_INTERVAL = 5 * minute;
|
|
|
33
34
|
export const TABLE_REFRESH_QUERY_TIMEOUT = 30 * second;
|
|
34
35
|
// When a timeout is not specified, run a query for this long
|
|
35
36
|
export const DEFAULT_QUERY_TIMEOUT = 180 * second;
|
|
37
|
+
// used to ensure connections to our closest peers remain open
|
|
38
|
+
export const KEEP_ALIVE_TAG = `${KEEP_ALIVE}-kad-dht`;
|
|
36
39
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,sFAAsF;AACtF,0BAA0B;AAC1B,+EAA+E;AAC/E,oFAAoF;AACpF,0EAA0E;A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,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,GAAG,MAAM,CAAA;AAE5C,qCAAqC;AACrC,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,GAAG,MAAM,CAAA;AAEhD,yCAAyC;AACzC,MAAM,CAAC,MAAM,2BAA2B,GAAG,EAAE,GAAG,MAAM,CAAA;AAEtD,6DAA6D;AAC7D,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,GAAG,MAAM,CAAA;AAEjD,8DAA8D;AAC9D,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,UAAU,UAAU,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { KEEP_ALIVE } from '@libp2p/interface';
|
|
2
1
|
import { PeerSet } from '@libp2p/peer-collections';
|
|
2
|
+
import { KEEP_ALIVE_TAG } from '../constants.js';
|
|
3
3
|
import { PeerDistanceList } from '../peer-distance-list.js';
|
|
4
4
|
import { convertPeerId } from '../utils.js';
|
|
5
5
|
export const PEER_SET_SIZE = 20;
|
|
@@ -66,7 +66,7 @@ export class ClosestPeers {
|
|
|
66
66
|
[this.closeTagName]: {
|
|
67
67
|
value: this.closeTagValue
|
|
68
68
|
},
|
|
69
|
-
[
|
|
69
|
+
[KEEP_ALIVE_TAG]: {
|
|
70
70
|
value: 1
|
|
71
71
|
}
|
|
72
72
|
}
|
|
@@ -76,7 +76,7 @@ export class ClosestPeers {
|
|
|
76
76
|
await this.components.peerStore.merge(peerId, {
|
|
77
77
|
tags: {
|
|
78
78
|
[this.closeTagName]: undefined,
|
|
79
|
-
[
|
|
79
|
+
[KEEP_ALIVE_TAG]: undefined
|
|
80
80
|
}
|
|
81
81
|
});
|
|
82
82
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"closest-peers.js","sourceRoot":"","sources":["../../../src/routing-table/closest-peers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"closest-peers.js","sourceRoot":"","sources":["../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AAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAA;QACzE,MAAM,KAAK,GAAG,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;QACtD,MAAM,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,UAAU,CAAC,CAAA;QACxD,IAAI,CAAC,YAAY,GAAG,UAAU,CAAA;QAE9B,MAAM,OAAO,CAAC,GAAG,CAAC;YAChB,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,KAAK,EAAC,MAAM,EAAC,EAAE;gBAC/B,MAAM,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,EAAE;oBAC5C,IAAI,EAAE;wBACJ,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE;4BACnB,KAAK,EAAE,IAAI,CAAC,aAAa;yBAC1B;wBACD,CAAC,cAAc,CAAC,EAAE;4BAChB,KAAK,EAAE,CAAC;yBACT;qBACF;iBACF,CAAC,CAAA;YACJ,CAAC,CAAC;YACF,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,CAAC,KAAK,EAAC,MAAM,EAAC,EAAE;gBACjC,MAAM,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,EAAE;oBAC5C,IAAI,EAAE;wBACJ,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,SAAS;wBAC9B,CAAC,cAAc,CAAC,EAAE,SAAS;qBAC5B;iBACF,CAAC,CAAA;YACJ,CAAC,CAAC;SACH,CAAC,CAAA;IACJ,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/kad-dht",
|
|
3
|
-
"version": "14.0.
|
|
3
|
+
"version": "14.0.1",
|
|
4
4
|
"description": "JavaScript implementation of the Kad-DHT for libp2p",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/kad-dht#readme",
|
|
@@ -57,13 +57,13 @@
|
|
|
57
57
|
"doc-check": "aegir doc-check"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@libp2p/crypto": "^5.0.
|
|
61
|
-
"@libp2p/interface": "^2.1.
|
|
62
|
-
"@libp2p/interface-internal": "^2.0.
|
|
63
|
-
"@libp2p/peer-collections": "^6.0.
|
|
64
|
-
"@libp2p/peer-id": "^5.0.
|
|
60
|
+
"@libp2p/crypto": "^5.0.5",
|
|
61
|
+
"@libp2p/interface": "^2.1.3",
|
|
62
|
+
"@libp2p/interface-internal": "^2.0.8",
|
|
63
|
+
"@libp2p/peer-collections": "^6.0.8",
|
|
64
|
+
"@libp2p/peer-id": "^5.0.5",
|
|
65
65
|
"@libp2p/record": "^4.0.4",
|
|
66
|
-
"@libp2p/utils": "^6.1.
|
|
66
|
+
"@libp2p/utils": "^6.1.1",
|
|
67
67
|
"@multiformats/multiaddr": "^12.2.3",
|
|
68
68
|
"any-signal": "^4.1.1",
|
|
69
69
|
"hashlru": "^2.3.0",
|
|
@@ -89,9 +89,9 @@
|
|
|
89
89
|
"uint8arrays": "^5.1.0"
|
|
90
90
|
},
|
|
91
91
|
"devDependencies": {
|
|
92
|
-
"@libp2p/interface-compliance-tests": "^6.1.
|
|
93
|
-
"@libp2p/logger": "^5.1.
|
|
94
|
-
"@libp2p/peer-store": "^11.0.
|
|
92
|
+
"@libp2p/interface-compliance-tests": "^6.1.6",
|
|
93
|
+
"@libp2p/logger": "^5.1.1",
|
|
94
|
+
"@libp2p/peer-store": "^11.0.8",
|
|
95
95
|
"@types/lodash.random": "^3.2.9",
|
|
96
96
|
"@types/lodash.range": "^3.2.9",
|
|
97
97
|
"@types/sinon": "^17.0.3",
|
package/src/constants.ts
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
// until the year 2020 (a great time in the future). For that record to stick around
|
|
6
6
|
// it must be rebroadcasted more frequently than once every 'MaxRecordAge'
|
|
7
7
|
|
|
8
|
+
import { KEEP_ALIVE } from '@libp2p/interface'
|
|
9
|
+
|
|
8
10
|
export const second = 1000
|
|
9
11
|
export const minute = 60 * second
|
|
10
12
|
export const hour = 60 * minute
|
|
@@ -51,3 +53,6 @@ export const TABLE_REFRESH_QUERY_TIMEOUT = 30 * second
|
|
|
51
53
|
|
|
52
54
|
// When a timeout is not specified, run a query for this long
|
|
53
55
|
export const DEFAULT_QUERY_TIMEOUT = 180 * second
|
|
56
|
+
|
|
57
|
+
// used to ensure connections to our closest peers remain open
|
|
58
|
+
export const KEEP_ALIVE_TAG = `${KEEP_ALIVE}-kad-dht`
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { KEEP_ALIVE } from '@libp2p/interface'
|
|
2
1
|
import { PeerSet } from '@libp2p/peer-collections'
|
|
2
|
+
import { KEEP_ALIVE_TAG } from '../constants.js'
|
|
3
3
|
import { PeerDistanceList } from '../peer-distance-list.js'
|
|
4
4
|
import { convertPeerId } from '../utils.js'
|
|
5
5
|
import type { RoutingTable } from './index.js'
|
|
@@ -94,7 +94,7 @@ export class ClosestPeers implements Startable {
|
|
|
94
94
|
[this.closeTagName]: {
|
|
95
95
|
value: this.closeTagValue
|
|
96
96
|
},
|
|
97
|
-
[
|
|
97
|
+
[KEEP_ALIVE_TAG]: {
|
|
98
98
|
value: 1
|
|
99
99
|
}
|
|
100
100
|
}
|
|
@@ -104,7 +104,7 @@ export class ClosestPeers implements Startable {
|
|
|
104
104
|
await this.components.peerStore.merge(peerId, {
|
|
105
105
|
tags: {
|
|
106
106
|
[this.closeTagName]: undefined,
|
|
107
|
-
[
|
|
107
|
+
[KEEP_ALIVE_TAG]: undefined
|
|
108
108
|
}
|
|
109
109
|
})
|
|
110
110
|
})
|