@lodestar/reqresp 1.41.0-dev.a35cbde8b3 → 1.41.0-dev.aeab9f930d
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/README.md +1 -1
- package/lib/ReqResp.d.ts +3 -3
- package/lib/ReqResp.d.ts.map +1 -1
- package/lib/ReqResp.js +4 -4
- package/lib/ReqResp.js.map +1 -1
- package/lib/encoders/requestDecode.d.ts +2 -3
- package/lib/encoders/requestDecode.d.ts.map +1 -1
- package/lib/encoders/requestDecode.js +28 -11
- package/lib/encoders/requestDecode.js.map +1 -1
- package/lib/encoders/requestEncode.d.ts +1 -1
- package/lib/encoders/requestEncode.d.ts.map +1 -1
- package/lib/encoders/requestEncode.js +1 -1
- package/lib/encoders/requestEncode.js.map +1 -1
- package/lib/encoders/responseDecode.d.ts +10 -10
- package/lib/encoders/responseDecode.d.ts.map +1 -1
- package/lib/encoders/responseDecode.js +63 -60
- package/lib/encoders/responseDecode.js.map +1 -1
- package/lib/encoders/responseEncode.d.ts +2 -4
- package/lib/encoders/responseEncode.d.ts.map +1 -1
- package/lib/encoders/responseEncode.js +13 -22
- package/lib/encoders/responseEncode.js.map +1 -1
- package/lib/encodingStrategies/index.d.ts +4 -3
- package/lib/encodingStrategies/index.d.ts.map +1 -1
- package/lib/encodingStrategies/index.js +4 -4
- package/lib/encodingStrategies/index.js.map +1 -1
- package/lib/encodingStrategies/sszSnappy/decode.d.ts +5 -4
- package/lib/encodingStrategies/sszSnappy/decode.d.ts.map +1 -1
- package/lib/encodingStrategies/sszSnappy/decode.js +83 -52
- package/lib/encodingStrategies/sszSnappy/decode.js.map +1 -1
- package/lib/encodingStrategies/sszSnappy/encode.d.ts +2 -2
- package/lib/encodingStrategies/sszSnappy/encode.d.ts.map +1 -1
- package/lib/encodingStrategies/sszSnappy/encode.js +1 -1
- package/lib/encodingStrategies/sszSnappy/encode.js.map +1 -1
- package/lib/encodingStrategies/sszSnappy/errors.d.ts +0 -8
- package/lib/encodingStrategies/sszSnappy/errors.d.ts.map +1 -1
- package/lib/encodingStrategies/sszSnappy/errors.js +2 -3
- package/lib/encodingStrategies/sszSnappy/errors.js.map +1 -1
- package/lib/encodingStrategies/sszSnappy/index.d.ts +0 -1
- package/lib/encodingStrategies/sszSnappy/index.d.ts.map +1 -1
- package/lib/encodingStrategies/sszSnappy/index.js +0 -1
- package/lib/encodingStrategies/sszSnappy/index.js.map +1 -1
- package/lib/encodingStrategies/sszSnappy/utils.js.map +1 -1
- package/lib/interface.js +2 -1
- package/lib/interface.js.map +1 -1
- package/lib/metrics.d.ts +1 -7
- package/lib/metrics.d.ts.map +1 -1
- package/lib/metrics.js +1 -17
- package/lib/metrics.js.map +1 -1
- package/lib/rate_limiter/ReqRespRateLimiter.d.ts.map +1 -1
- package/lib/rate_limiter/ReqRespRateLimiter.js.map +1 -1
- package/lib/rate_limiter/rateLimiterGRCA.d.ts.map +1 -1
- package/lib/rate_limiter/rateLimiterGRCA.js.map +1 -1
- package/lib/rate_limiter/selfRateLimiter.d.ts.map +1 -1
- package/lib/rate_limiter/selfRateLimiter.js.map +1 -1
- package/lib/request/errors.d.ts +1 -7
- package/lib/request/errors.d.ts.map +1 -1
- package/lib/request/errors.js +3 -6
- package/lib/request/errors.js.map +1 -1
- package/lib/request/index.d.ts +0 -3
- package/lib/request/index.d.ts.map +1 -1
- package/lib/request/index.js +85 -70
- package/lib/request/index.js.map +1 -1
- package/lib/response/errors.d.ts.map +1 -1
- package/lib/response/errors.js +2 -1
- package/lib/response/errors.js.map +1 -1
- package/lib/response/index.d.ts +2 -2
- package/lib/response/index.d.ts.map +1 -1
- package/lib/response/index.js +46 -50
- package/lib/response/index.js.map +1 -1
- package/lib/types.d.ts +1 -2
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js +7 -5
- package/lib/types.js.map +1 -1
- package/lib/utils/collectExactOne.js.map +1 -1
- package/lib/utils/collectMaxResponse.d.ts.map +1 -1
- package/lib/utils/collectMaxResponse.js +1 -2
- package/lib/utils/collectMaxResponse.js.map +1 -1
- package/lib/utils/errorMessage.d.ts +3 -3
- package/lib/utils/errorMessage.d.ts.map +1 -1
- package/lib/utils/errorMessage.js +14 -13
- package/lib/utils/errorMessage.js.map +1 -1
- package/lib/utils/index.d.ts +1 -3
- package/lib/utils/index.d.ts.map +1 -1
- package/lib/utils/index.js +1 -3
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/peerId.js.map +1 -1
- package/lib/utils/protocolId.d.ts +2 -2
- package/lib/utils/protocolId.js +2 -2
- package/lib/utils/protocolId.js.map +1 -1
- package/lib/utils/snappyCommon.js +2 -1
- package/lib/utils/snappyCommon.js.map +1 -1
- package/lib/utils/snappyCompress.d.ts +1 -1
- package/lib/utils/snappyCompress.d.ts.map +1 -1
- package/lib/utils/snappyCompress.js +1 -1
- package/lib/utils/snappyCompress.js.map +1 -1
- package/lib/utils/snappyIndex.d.ts +1 -1
- package/lib/utils/snappyIndex.d.ts.map +1 -1
- package/lib/utils/snappyIndex.js +1 -1
- package/lib/utils/snappyIndex.js.map +1 -1
- package/lib/utils/snappyUncompress.d.ts +7 -11
- package/lib/utils/snappyUncompress.d.ts.map +1 -1
- package/lib/utils/snappyUncompress.js +68 -68
- package/lib/utils/snappyUncompress.js.map +1 -1
- package/lib/utils/stream.d.ts +6 -0
- package/lib/utils/stream.d.ts.map +1 -0
- package/lib/utils/stream.js +21 -0
- package/lib/utils/stream.js.map +1 -0
- package/package.json +16 -18
- package/src/ReqResp.ts +4 -4
- package/src/encoders/requestDecode.ts +32 -16
- package/src/encoders/requestEncode.ts +1 -1
- package/src/encoders/responseDecode.ts +68 -72
- package/src/encoders/responseEncode.ts +17 -29
- package/src/encodingStrategies/index.ts +8 -6
- package/src/encodingStrategies/sszSnappy/decode.ts +111 -53
- package/src/encodingStrategies/sszSnappy/encode.ts +2 -2
- package/src/encodingStrategies/sszSnappy/errors.ts +0 -4
- package/src/encodingStrategies/sszSnappy/index.ts +0 -1
- package/src/metrics.ts +1 -17
- package/src/request/errors.ts +1 -6
- package/src/request/index.ts +109 -86
- package/src/response/index.ts +55 -61
- package/src/types.ts +1 -3
- package/src/utils/collectMaxResponse.ts +1 -2
- package/src/utils/errorMessage.ts +14 -13
- package/src/utils/index.ts +1 -3
- package/src/utils/protocolId.ts +2 -2
- package/src/utils/snappyCompress.ts +1 -1
- package/src/utils/snappyIndex.ts +1 -1
- package/src/utils/snappyUncompress.ts +73 -75
- package/src/utils/stream.ts +34 -0
- package/lib/utils/abortableSource.d.ts +0 -12
- package/lib/utils/abortableSource.d.ts.map +0 -1
- package/lib/utils/abortableSource.js +0 -69
- package/lib/utils/abortableSource.js.map +0 -1
- package/lib/utils/bufferedSource.d.ts +0 -16
- package/lib/utils/bufferedSource.d.ts.map +0 -1
- package/lib/utils/bufferedSource.js +0 -40
- package/lib/utils/bufferedSource.js.map +0 -1
- package/lib/utils/onChunk.d.ts +0 -6
- package/lib/utils/onChunk.d.ts.map +0 -1
- package/lib/utils/onChunk.js +0 -13
- package/lib/utils/onChunk.js.map +0 -1
- package/lib/utils/snappy.d.ts +0 -3
- package/lib/utils/snappy.d.ts.map +0 -1
- package/lib/utils/snappy.js +0 -3
- package/lib/utils/snappy.js.map +0 -1
- package/src/utils/abortableSource.ts +0 -80
- package/src/utils/bufferedSource.ts +0 -46
- package/src/utils/onChunk.ts +0 -12
- package/src/utils/snappy.ts +0 -2
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { Uint8ArrayList } from "uint8arraylist";
|
|
2
|
-
/**
|
|
3
|
-
* Wraps a buffer chunk stream source with another async iterable
|
|
4
|
-
* so it can be reused in multiple for..of statements.
|
|
5
|
-
*
|
|
6
|
-
* Uses a BufferList internally to make sure all chunks are consumed
|
|
7
|
-
* when switching consumers
|
|
8
|
-
*/
|
|
9
|
-
export class BufferedSource {
|
|
10
|
-
isDone = false;
|
|
11
|
-
buffer;
|
|
12
|
-
source;
|
|
13
|
-
constructor(source) {
|
|
14
|
-
this.buffer = new Uint8ArrayList();
|
|
15
|
-
this.source = source;
|
|
16
|
-
}
|
|
17
|
-
[Symbol.asyncIterator]() {
|
|
18
|
-
const that = this;
|
|
19
|
-
let firstNext = true;
|
|
20
|
-
return {
|
|
21
|
-
async next() {
|
|
22
|
-
// Prevent fetching a new chunk if there are pending bytes
|
|
23
|
-
// not processed by a previous consumer of this BufferedSource
|
|
24
|
-
if (firstNext && that.buffer.length > 0) {
|
|
25
|
-
firstNext = false;
|
|
26
|
-
return { done: false, value: that.buffer };
|
|
27
|
-
}
|
|
28
|
-
const { done, value: chunk } = await that.source.next();
|
|
29
|
-
if (done === true) {
|
|
30
|
-
that.isDone = true;
|
|
31
|
-
return { done: true, value: undefined };
|
|
32
|
-
}
|
|
33
|
-
// Concat new chunk and return a reference to its BufferList instance
|
|
34
|
-
that.buffer.append(chunk);
|
|
35
|
-
return { done: false, value: that.buffer };
|
|
36
|
-
},
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
//# sourceMappingURL=bufferedSource.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bufferedSource.js","sourceRoot":"","sources":["../../src/utils/bufferedSource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,gBAAgB,CAAC;AAE9C;;;;;;GAMG;AACH,MAAM,OAAO,cAAc;IACzB,MAAM,GAAG,KAAK,CAAC;IACP,MAAM,CAAiB;IACvB,MAAM,CAA8C;IAE5D,YAAY,MAAmD;QAC7D,IAAI,CAAC,MAAM,GAAG,IAAI,cAAc,EAAE,CAAC;QACnC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,CAAC,MAAM,CAAC,aAAa,CAAC;QACpB,MAAM,IAAI,GAAG,IAAI,CAAC;QAElB,IAAI,SAAS,GAAG,IAAI,CAAC;QAErB,OAAO;YACL,KAAK,CAAC,IAAI;gBACR,0DAA0D;gBAC1D,8DAA8D;gBAC9D,IAAI,SAAS,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBACxC,SAAS,GAAG,KAAK,CAAC;oBAClB,OAAO,EAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,EAAC,CAAC;gBAC3C,CAAC;gBAED,MAAM,EAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAC,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;gBACtD,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;oBAClB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;oBACnB,OAAO,EAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAC,CAAC;gBACxC,CAAC;gBAED,qEAAqE;gBACrE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBAC1B,OAAO,EAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,EAAC,CAAC;YAC3C,CAAC;SACF,CAAC;IACJ,CAAC;CACF"}
|
package/lib/utils/onChunk.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Calls `callback` with each `chunk` received from the `source` AsyncIterable
|
|
3
|
-
* Useful for logging, or cancelling timeouts
|
|
4
|
-
*/
|
|
5
|
-
export declare function onChunk<T>(callback: (chunk: T) => void): (source: AsyncIterable<T>) => AsyncIterable<T>;
|
|
6
|
-
//# sourceMappingURL=onChunk.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"onChunk.d.ts","sourceRoot":"","sources":["../../src/utils/onChunk.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,KAAK,aAAa,CAAC,CAAC,CAAC,CAOvG"}
|
package/lib/utils/onChunk.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Calls `callback` with each `chunk` received from the `source` AsyncIterable
|
|
3
|
-
* Useful for logging, or cancelling timeouts
|
|
4
|
-
*/
|
|
5
|
-
export function onChunk(callback) {
|
|
6
|
-
return async function* onChunkTransform(source) {
|
|
7
|
-
for await (const chunk of source) {
|
|
8
|
-
callback(chunk);
|
|
9
|
-
yield chunk;
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=onChunk.js.map
|
package/lib/utils/onChunk.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"onChunk.js","sourceRoot":"","sources":["../../src/utils/onChunk.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAI,QAA4B;IACrD,OAAO,KAAK,SAAS,CAAC,CAAC,gBAAgB,CAAC,MAAM;QAC5C,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YACjC,QAAQ,CAAC,KAAK,CAAC,CAAC;YAChB,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
package/lib/utils/snappy.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"snappy.d.ts","sourceRoot":"","sources":["../../src/utils/snappy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,IAAI,QAAQ,EAAC,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC"}
|
package/lib/utils/snappy.js
DELETED
package/lib/utils/snappy.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"snappy.js","sourceRoot":"","sources":["../../src/utils/snappy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,IAAI,QAAQ,EAAC,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAC,UAAU,EAAC,MAAM,UAAU,CAAC"}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Wraps an AsyncIterable and rejects early if any signal aborts.
|
|
3
|
-
* Throws the error returned by `getError()` of each signal options.
|
|
4
|
-
*
|
|
5
|
-
* Simplified fork of `"abortable-iterator"`.
|
|
6
|
-
* Read function's source for reasoning of the fork.
|
|
7
|
-
*/
|
|
8
|
-
export function abortableSource<T>(
|
|
9
|
-
sourceArg: AsyncIterable<T>,
|
|
10
|
-
signals: {
|
|
11
|
-
signal: AbortSignal;
|
|
12
|
-
getError: () => Error;
|
|
13
|
-
}[]
|
|
14
|
-
): AsyncIterable<T> {
|
|
15
|
-
const source = sourceArg as AsyncGenerator<T>;
|
|
16
|
-
|
|
17
|
-
async function* abortable(): AsyncIterable<T> {
|
|
18
|
-
// Handler that will hold a reference to the `abort()` promise,
|
|
19
|
-
// necessary for the signal abort listeners to reject the iterable promise
|
|
20
|
-
let nextAbortHandler: ((error: Error) => void) | null = null;
|
|
21
|
-
|
|
22
|
-
// For each signal register an abortHandler(), and prepare clean-up with `onDoneCbs`
|
|
23
|
-
const onDoneCbs: (() => void)[] = [];
|
|
24
|
-
for (const {signal, getError} of signals) {
|
|
25
|
-
const abortHandler = (): void => {
|
|
26
|
-
if (nextAbortHandler) nextAbortHandler(getError());
|
|
27
|
-
};
|
|
28
|
-
signal.addEventListener("abort", abortHandler);
|
|
29
|
-
onDoneCbs.push(() => {
|
|
30
|
-
signal.removeEventListener("abort", abortHandler);
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
try {
|
|
35
|
-
while (true) {
|
|
36
|
-
// Abort early if any signal is aborted
|
|
37
|
-
for (const {signal, getError} of signals) {
|
|
38
|
-
if (signal.aborted) {
|
|
39
|
-
throw getError();
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// Race the iterator and the abort signals
|
|
44
|
-
const result = await Promise.race([
|
|
45
|
-
new Promise<never>((_, reject) => {
|
|
46
|
-
nextAbortHandler = (error) => reject(error);
|
|
47
|
-
}),
|
|
48
|
-
source.next(),
|
|
49
|
-
]);
|
|
50
|
-
|
|
51
|
-
// source.next() resolved first
|
|
52
|
-
nextAbortHandler = null;
|
|
53
|
-
|
|
54
|
-
if (result.done) {
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
yield result.value;
|
|
59
|
-
}
|
|
60
|
-
} catch (err) {
|
|
61
|
-
// End the iterator if it is a generator
|
|
62
|
-
if (typeof source.return === "function") {
|
|
63
|
-
// This source.return() function may never resolve depending on the source AsyncGenerator implementation.
|
|
64
|
-
// This is the main reason to fork "abortable-iterator", which caused our node to get stuck during Sync.
|
|
65
|
-
// We choose to call .return() but not await it. In general, source.return should never throw. If it does,
|
|
66
|
-
// it a problem of the source implementor, and thus logged as an unhandled rejection. If that happens,
|
|
67
|
-
// the source implementor should fix the upstream code.
|
|
68
|
-
void source.return(null);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
throw err;
|
|
72
|
-
} finally {
|
|
73
|
-
for (const cb of onDoneCbs) {
|
|
74
|
-
cb();
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return abortable();
|
|
80
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import {Uint8ArrayList} from "uint8arraylist";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Wraps a buffer chunk stream source with another async iterable
|
|
5
|
-
* so it can be reused in multiple for..of statements.
|
|
6
|
-
*
|
|
7
|
-
* Uses a BufferList internally to make sure all chunks are consumed
|
|
8
|
-
* when switching consumers
|
|
9
|
-
*/
|
|
10
|
-
export class BufferedSource {
|
|
11
|
-
isDone = false;
|
|
12
|
-
private buffer: Uint8ArrayList;
|
|
13
|
-
private source: AsyncGenerator<Uint8ArrayList | Uint8Array>;
|
|
14
|
-
|
|
15
|
-
constructor(source: AsyncGenerator<Uint8ArrayList | Uint8Array>) {
|
|
16
|
-
this.buffer = new Uint8ArrayList();
|
|
17
|
-
this.source = source;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
[Symbol.asyncIterator](): AsyncIterator<Uint8ArrayList> {
|
|
21
|
-
const that = this;
|
|
22
|
-
|
|
23
|
-
let firstNext = true;
|
|
24
|
-
|
|
25
|
-
return {
|
|
26
|
-
async next() {
|
|
27
|
-
// Prevent fetching a new chunk if there are pending bytes
|
|
28
|
-
// not processed by a previous consumer of this BufferedSource
|
|
29
|
-
if (firstNext && that.buffer.length > 0) {
|
|
30
|
-
firstNext = false;
|
|
31
|
-
return {done: false, value: that.buffer};
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const {done, value: chunk} = await that.source.next();
|
|
35
|
-
if (done === true) {
|
|
36
|
-
that.isDone = true;
|
|
37
|
-
return {done: true, value: undefined};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// Concat new chunk and return a reference to its BufferList instance
|
|
41
|
-
that.buffer.append(chunk);
|
|
42
|
-
return {done: false, value: that.buffer};
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
}
|
package/src/utils/onChunk.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Calls `callback` with each `chunk` received from the `source` AsyncIterable
|
|
3
|
-
* Useful for logging, or cancelling timeouts
|
|
4
|
-
*/
|
|
5
|
-
export function onChunk<T>(callback: (chunk: T) => void): (source: AsyncIterable<T>) => AsyncIterable<T> {
|
|
6
|
-
return async function* onChunkTransform(source) {
|
|
7
|
-
for await (const chunk of source) {
|
|
8
|
-
callback(chunk);
|
|
9
|
-
yield chunk;
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
}
|
package/src/utils/snappy.ts
DELETED