@lodestar/reqresp 1.16.0-rc.0 → 1.16.0
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/lib/ReqResp.d.ts +3 -3
- package/lib/ReqResp.js +8 -10
- package/lib/ReqResp.js.map +1 -1
- package/package.json +7 -7
package/lib/ReqResp.d.ts
CHANGED
|
@@ -45,17 +45,17 @@ export declare class ReqResp {
|
|
|
45
45
|
*
|
|
46
46
|
* Made it explicit method to avoid any developer mistake
|
|
47
47
|
*/
|
|
48
|
-
registerDialOnlyProtocol(protocol: DialOnlyProtocol
|
|
48
|
+
registerDialOnlyProtocol(protocol: DialOnlyProtocol): void;
|
|
49
49
|
/**
|
|
50
50
|
* Register protocol as supported and to libp2p.
|
|
51
|
-
* async because libp2p
|
|
51
|
+
* async because libp2p registrar persists the new protocol list in the peer-store.
|
|
52
52
|
* Throws if the same protocol is registered twice.
|
|
53
53
|
* Can be called at any time, no concept of started / stopped
|
|
54
54
|
*/
|
|
55
55
|
registerProtocol(protocol: Protocol, opts?: ReqRespRegisterOpts): Promise<void>;
|
|
56
56
|
/**
|
|
57
57
|
* Remove protocol as supported and from libp2p.
|
|
58
|
-
* async because libp2p
|
|
58
|
+
* async because libp2p registrar persists the new protocol list in the peer-store.
|
|
59
59
|
* Does NOT throw if the protocolID is unknown.
|
|
60
60
|
* Can be called at any time, no concept of started / stopped
|
|
61
61
|
*/
|
package/lib/ReqResp.js
CHANGED
|
@@ -18,8 +18,6 @@ export class ReqResp {
|
|
|
18
18
|
/** Tracks request and responses in a sequential counter */
|
|
19
19
|
this.reqCount = 0;
|
|
20
20
|
/** `${protocolPrefix}/${method}/${version}/${encoding}` */
|
|
21
|
-
// Use any to avoid TS error on registering protocol
|
|
22
|
-
// Type 'unknown' is not assignable to type 'Resp'
|
|
23
21
|
this.registeredProtocols = new Map();
|
|
24
22
|
this.dialOnlyProtocols = new Map();
|
|
25
23
|
this.libp2p = modules.libp2p;
|
|
@@ -34,25 +32,25 @@ export class ReqResp {
|
|
|
34
32
|
*
|
|
35
33
|
* Made it explicit method to avoid any developer mistake
|
|
36
34
|
*/
|
|
37
|
-
registerDialOnlyProtocol(protocol
|
|
35
|
+
registerDialOnlyProtocol(protocol) {
|
|
38
36
|
const protocolID = this.formatProtocolID(protocol);
|
|
39
|
-
// libp2p will throw on error on duplicates, allow to overwrite behavior
|
|
40
|
-
if (opts?.ignoreIfDuplicate && this.registeredProtocols.has(protocolID)) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
37
|
this.registeredProtocols.set(protocolID, protocol);
|
|
44
38
|
this.dialOnlyProtocols.set(protocolID, true);
|
|
45
39
|
}
|
|
46
40
|
/**
|
|
47
41
|
* Register protocol as supported and to libp2p.
|
|
48
|
-
* async because libp2p
|
|
42
|
+
* async because libp2p registrar persists the new protocol list in the peer-store.
|
|
49
43
|
* Throws if the same protocol is registered twice.
|
|
50
44
|
* Can be called at any time, no concept of started / stopped
|
|
51
45
|
*/
|
|
52
46
|
async registerProtocol(protocol, opts) {
|
|
53
47
|
const protocolID = this.formatProtocolID(protocol);
|
|
48
|
+
// libp2p will throw if handler for protocol is already registered, allow to overwrite behavior
|
|
49
|
+
if (opts?.ignoreIfDuplicate && this.registeredProtocols.has(protocolID)) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
54
52
|
const { handler: _handler, inboundRateLimits, ...rest } = protocol;
|
|
55
|
-
this.registerDialOnlyProtocol(rest
|
|
53
|
+
this.registerDialOnlyProtocol(rest);
|
|
56
54
|
this.dialOnlyProtocols.set(protocolID, false);
|
|
57
55
|
if (inboundRateLimits) {
|
|
58
56
|
this.rateLimiter.initRateLimits(protocolID, inboundRateLimits);
|
|
@@ -61,7 +59,7 @@ export class ReqResp {
|
|
|
61
59
|
}
|
|
62
60
|
/**
|
|
63
61
|
* Remove protocol as supported and from libp2p.
|
|
64
|
-
* async because libp2p
|
|
62
|
+
* async because libp2p registrar persists the new protocol list in the peer-store.
|
|
65
63
|
* Does NOT throw if the protocolID is unknown.
|
|
66
64
|
* Can be called at any time, no concept of started / stopped
|
|
67
65
|
*/
|
package/lib/ReqResp.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReqResp.js","sourceRoot":"","sources":["../src/ReqResp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,aAAa,CAAC;AAI5C,OAAO,EAAC,UAAU,EAAU,MAAM,cAAc,CAAC;AACjD,OAAO,EAAC,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAkB,MAAM,oBAAoB,CAAC;AAChG,OAAO,EAAC,aAAa,EAAC,MAAM,qBAAqB,CAAC;AAUlD,OAAO,EAAC,gBAAgB,EAAC,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAC,kBAAkB,EAAC,MAAM,sCAAsC,CAAC;AAIxE,MAAM,CAAC,MAAM,uBAAuB,GAAG,wBAAwB,CAAC;AAkBhE;;;;;GAKG;AACH,MAAM,OAAO,OAAO;
|
|
1
|
+
{"version":3,"file":"ReqResp.js","sourceRoot":"","sources":["../src/ReqResp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,aAAa,CAAC;AAI5C,OAAO,EAAC,UAAU,EAAU,MAAM,cAAc,CAAC;AACjD,OAAO,EAAC,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAkB,MAAM,oBAAoB,CAAC;AAChG,OAAO,EAAC,aAAa,EAAC,MAAM,qBAAqB,CAAC;AAUlD,OAAO,EAAC,gBAAgB,EAAC,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAC,kBAAkB,EAAC,MAAM,sCAAsC,CAAC;AAIxE,MAAM,CAAC,MAAM,uBAAuB,GAAG,wBAAwB,CAAC;AAkBhE;;;;;GAKG;AACH,MAAM,OAAO,OAAO;IAiBlB,YACE,OAA+B,EACd,OAAoB,EAAE;QAAtB,SAAI,GAAJ,IAAI,CAAkB;QAXjC,eAAU,G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package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"bugs": {
|
|
12
12
|
"url": "https://github.com/ChainSafe/lodestar/issues"
|
|
13
13
|
},
|
|
14
|
-
"version": "1.16.0
|
|
14
|
+
"version": "1.16.0",
|
|
15
15
|
"type": "module",
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
@@ -54,9 +54,9 @@
|
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@chainsafe/fast-crc32c": "^4.1.1",
|
|
56
56
|
"@libp2p/interface": "^1.1.1",
|
|
57
|
-
"@lodestar/config": "1.16.0
|
|
58
|
-
"@lodestar/params": "1.16.0
|
|
59
|
-
"@lodestar/utils": "1.16.0
|
|
57
|
+
"@lodestar/config": "^1.16.0",
|
|
58
|
+
"@lodestar/params": "^1.16.0",
|
|
59
|
+
"@lodestar/utils": "^1.16.0",
|
|
60
60
|
"it-all": "^3.0.4",
|
|
61
61
|
"it-pipe": "^3.0.1",
|
|
62
62
|
"snappy": "^7.2.2",
|
|
@@ -65,8 +65,8 @@
|
|
|
65
65
|
"uint8arraylist": "^2.4.7"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@lodestar/logger": "1.16.0
|
|
69
|
-
"@lodestar/types": "1.16.0
|
|
68
|
+
"@lodestar/logger": "^1.16.0",
|
|
69
|
+
"@lodestar/types": "^1.16.0",
|
|
70
70
|
"libp2p": "1.1.1"
|
|
71
71
|
},
|
|
72
72
|
"peerDependencies": {
|
|
@@ -80,5 +80,5 @@
|
|
|
80
80
|
"reqresp",
|
|
81
81
|
"blockchain"
|
|
82
82
|
],
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "14ea6549b08c0375b0f1167413474627fdbcbf66"
|
|
84
84
|
}
|