@libp2p/mplex 9.0.12 → 10.0.0-551622a96
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +6 -4
- package/dist/index.min.js +5 -5
- package/dist/src/decode.js.map +1 -1
- package/dist/src/encode.d.ts +2 -1
- package/dist/src/encode.d.ts.map +1 -1
- package/dist/src/encode.js +5 -21
- package/dist/src/encode.js.map +1 -1
- package/dist/src/index.d.ts +5 -13
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +5 -3
- package/dist/src/index.js.map +1 -1
- package/dist/src/mplex.d.ts +6 -6
- package/dist/src/mplex.d.ts.map +1 -1
- package/dist/src/mplex.js +32 -25
- package/dist/src/mplex.js.map +1 -1
- package/dist/src/stream.d.ts +3 -1
- package/dist/src/stream.d.ts.map +1 -1
- package/dist/src/stream.js +2 -3
- package/dist/src/stream.js.map +1 -1
- package/package.json +14 -11
- package/src/encode.ts +5 -25
- package/src/index.ts +11 -17
- package/src/mplex.ts +38 -33
- package/src/stream.ts +4 -3
- package/dist/typedoc-urls.json +0 -6
package/dist/src/index.d.ts
CHANGED
@@ -30,7 +30,7 @@
|
|
30
30
|
* pipe([1, 2, 3], stream)
|
31
31
|
* ```
|
32
32
|
*/
|
33
|
-
import type { StreamMuxerFactory } from '@libp2p/interface
|
33
|
+
import type { ComponentLogger, StreamMuxerFactory } from '@libp2p/interface';
|
34
34
|
export interface MplexInit {
|
35
35
|
/**
|
36
36
|
* The maximum size of message that can be sent in one go in bytes.
|
@@ -47,17 +47,6 @@ export interface MplexInit {
|
|
47
47
|
* (default: 4MB)
|
48
48
|
*/
|
49
49
|
maxUnprocessedMessageQueueSize?: number;
|
50
|
-
/**
|
51
|
-
* Each byte array written into a multiplexed stream is converted to one or
|
52
|
-
* more messages which are sent as byte arrays to the remote node. Sending
|
53
|
-
* lots of small messages can be expensive - use this setting to batch up
|
54
|
-
* the serialized bytes of all messages sent during the current tick up to
|
55
|
-
* this limit to send in one go similar to Nagle's algorithm. N.b. you
|
56
|
-
* should benchmark your application carefully when using this setting as it
|
57
|
-
* may cause the opposite of the desired effect. Omit this setting to send
|
58
|
-
* all messages as they become available. (default: undefined)
|
59
|
-
*/
|
60
|
-
minSendBytes?: number;
|
61
50
|
/**
|
62
51
|
* The maximum number of multiplexed streams that can be open at any
|
63
52
|
* one time. A request to open more than this will have a stream
|
@@ -83,5 +72,8 @@ export interface MplexInit {
|
|
83
72
|
*/
|
84
73
|
disconnectThreshold?: number;
|
85
74
|
}
|
86
|
-
export
|
75
|
+
export interface MplexComponents {
|
76
|
+
logger: ComponentLogger;
|
77
|
+
}
|
78
|
+
export declare function mplex(init?: MplexInit): (components: MplexComponents) => StreamMuxerFactory;
|
87
79
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/index.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAGH,OAAO,KAAK,EAAe,kBAAkB,EAAmB,MAAM,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAe,kBAAkB,EAAmB,MAAM,mBAAmB,CAAA;AAE1G,MAAM,WAAW,SAAS;IACxB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IAEnB;;;;;;OAMG;IACH,8BAA8B,CAAC,EAAE,MAAM,CAAA;IAEvC;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAE1B;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAE3B;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAA;IAE5B;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAA;CAC7B;AAoBD,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,eAAe,CAAA;CACxB;AAED,wBAAgB,KAAK,CAAE,IAAI,GAAE,SAAc,GAAG,CAAC,UAAU,EAAE,eAAe,KAAK,kBAAkB,CAEhG"}
|
package/dist/src/index.js
CHANGED
@@ -34,17 +34,19 @@ import { MplexStreamMuxer } from './mplex.js';
|
|
34
34
|
class Mplex {
|
35
35
|
protocol = '/mplex/6.7.0';
|
36
36
|
_init;
|
37
|
-
|
37
|
+
components;
|
38
|
+
constructor(components, init = {}) {
|
39
|
+
this.components = components;
|
38
40
|
this._init = init;
|
39
41
|
}
|
40
42
|
createStreamMuxer(init = {}) {
|
41
|
-
return new MplexStreamMuxer({
|
43
|
+
return new MplexStreamMuxer(this.components, {
|
42
44
|
...init,
|
43
45
|
...this._init
|
44
46
|
});
|
45
47
|
}
|
46
48
|
}
|
47
49
|
export function mplex(init = {}) {
|
48
|
-
return () => new Mplex(init);
|
50
|
+
return (components) => new Mplex(components, init);
|
49
51
|
}
|
50
52
|
//# sourceMappingURL=index.js.map
|
package/dist/src/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAkD7C,MAAM,KAAK;IACF,QAAQ,GAAG,cAAc,CAAA;IACf,KAAK,CAAW;IAChB,UAAU,CAAiB;IAE5C,YAAa,UAA2B,EAAE,OAAkB,EAAE;QAC5D,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;IACnB,CAAC;IAED,iBAAiB,CAAE,OAAwB,EAAE;QAC3C,OAAO,IAAI,gBAAgB,CAAC,IAAI,CAAC,UAAU,EAAE;YAC3C,GAAG,IAAI;YACP,GAAG,IAAI,CAAC,KAAK;SACd,CAAC,CAAA;IACJ,CAAC;CACF;AAMD,MAAM,UAAU,KAAK,CAAE,OAAkB,EAAE;IACzC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,KAAK,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;AACpD,CAAC"}
|
package/dist/src/mplex.d.ts
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
import { type Message } from './message-types.js';
|
2
2
|
import { type MplexStream } from './stream.js';
|
3
|
-
import type { MplexInit } from './index.js';
|
4
|
-
import type { AbortOptions } from '@libp2p/interface';
|
5
|
-
import type { Stream } from '@libp2p/interface/connection';
|
6
|
-
import type { StreamMuxer, StreamMuxerInit } from '@libp2p/interface/stream-muxer';
|
3
|
+
import type { MplexComponents, MplexInit } from './index.js';
|
4
|
+
import type { AbortOptions, Stream, StreamMuxer, StreamMuxerInit } from '@libp2p/interface';
|
7
5
|
import type { Sink, Source } from 'it-stream-types';
|
8
6
|
import type { Uint8ArrayList } from 'uint8arraylist';
|
9
7
|
interface MplexStreamMuxerInit extends MplexInit, StreamMuxerInit {
|
@@ -15,7 +13,8 @@ interface MplexStreamMuxerInit extends MplexInit, StreamMuxerInit {
|
|
15
13
|
export declare class MplexStreamMuxer implements StreamMuxer {
|
16
14
|
protocol: string;
|
17
15
|
sink: Sink<Source<Uint8ArrayList | Uint8Array>, Promise<void>>;
|
18
|
-
source: AsyncGenerator<Uint8Array>;
|
16
|
+
source: AsyncGenerator<Uint8ArrayList | Uint8Array>;
|
17
|
+
private readonly log;
|
19
18
|
private _streamId;
|
20
19
|
private readonly _streams;
|
21
20
|
private readonly _init;
|
@@ -23,7 +22,8 @@ export declare class MplexStreamMuxer implements StreamMuxer {
|
|
23
22
|
private readonly closeController;
|
24
23
|
private readonly rateLimiter;
|
25
24
|
private readonly closeTimeout;
|
26
|
-
|
25
|
+
private readonly logger;
|
26
|
+
constructor(components: MplexComponents, init?: MplexStreamMuxerInit);
|
27
27
|
/**
|
28
28
|
* Returns a Map of streams and their ids
|
29
29
|
*/
|
package/dist/src/mplex.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"mplex.d.ts","sourceRoot":"","sources":["../../src/mplex.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"mplex.d.ts","sourceRoot":"","sources":["../../src/mplex.ts"],"names":[],"mappings":"AAUA,OAAO,EAAkC,KAAK,OAAO,EAAE,MAAM,oBAAoB,CAAA;AACjF,OAAO,EAAgB,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAC5D,OAAO,KAAK,EAAE,YAAY,EAA2B,MAAM,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACpH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAyBpD,UAAU,oBAAqB,SAAQ,SAAS,EAAE,eAAe;IAC/D;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAED,qBAAa,gBAAiB,YAAW,WAAW;IAC3C,QAAQ,SAAiB;IAEzB,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,cAAc,GAAG,UAAU,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA;IAC9D,MAAM,EAAE,cAAc,CAAC,cAAc,GAAG,UAAU,CAAC,CAAA;IAE1D,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAQ;IAC5B,OAAO,CAAC,SAAS,CAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA+E;IACxG,OAAO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CodeError } from '@libp2p/interface';
|
3
|
+
import { closeSource } from '@libp2p/utils/close-source';
|
4
4
|
import { pipe } from 'it-pipe';
|
5
|
-
import {
|
5
|
+
import { pushable } from 'it-pushable';
|
6
6
|
import { RateLimiterMemory } from 'rate-limiter-flexible';
|
7
7
|
import { toString as uint8ArrayToString } from 'uint8arrays';
|
8
8
|
import { Decoder } from './decode.js';
|
9
9
|
import { encode } from './encode.js';
|
10
10
|
import { MessageTypes, MessageTypeNames } from './message-types.js';
|
11
11
|
import { createStream } from './stream.js';
|
12
|
-
const log = logger('libp2p:mplex');
|
13
12
|
const MAX_STREAMS_INBOUND_STREAMS_PER_CONNECTION = 1024;
|
14
13
|
const MAX_STREAMS_OUTBOUND_STREAMS_PER_CONNECTION = 1024;
|
15
14
|
const MAX_STREAM_BUFFER_SIZE = 1024 * 1024 * 4; // 4MB
|
@@ -32,6 +31,7 @@ export class MplexStreamMuxer {
|
|
32
31
|
protocol = '/mplex/6.7.0';
|
33
32
|
sink;
|
34
33
|
source;
|
34
|
+
log;
|
35
35
|
_streamId;
|
36
36
|
_streams;
|
37
37
|
_init;
|
@@ -39,8 +39,11 @@ export class MplexStreamMuxer {
|
|
39
39
|
closeController;
|
40
40
|
rateLimiter;
|
41
41
|
closeTimeout;
|
42
|
-
|
42
|
+
logger;
|
43
|
+
constructor(components, init) {
|
43
44
|
init = init ?? {};
|
45
|
+
this.log = components.logger.forComponent('libp2p:mplex');
|
46
|
+
this.logger = components.logger;
|
44
47
|
this._streamId = 0;
|
45
48
|
this._streams = {
|
46
49
|
/**
|
@@ -61,7 +64,7 @@ export class MplexStreamMuxer {
|
|
61
64
|
/**
|
62
65
|
* An iterable source
|
63
66
|
*/
|
64
|
-
this._source =
|
67
|
+
this._source = pushable({
|
65
68
|
objectMode: true,
|
66
69
|
onEnd: () => {
|
67
70
|
// the source has ended, we can't write any more messages to gracefully
|
@@ -74,7 +77,7 @@ export class MplexStreamMuxer {
|
|
74
77
|
}
|
75
78
|
}
|
76
79
|
});
|
77
|
-
this.source = pipe(this._source, source => encode(source
|
80
|
+
this.source = pipe(this._source, source => encode(source));
|
78
81
|
/**
|
79
82
|
* Close controller
|
80
83
|
*/
|
@@ -152,7 +155,7 @@ export class MplexStreamMuxer {
|
|
152
155
|
}
|
153
156
|
_newStream(options) {
|
154
157
|
const { id, name, type, registry } = options;
|
155
|
-
log('new %s stream %s', type, id);
|
158
|
+
this.log('new %s stream %s', type, id);
|
156
159
|
if (type === 'initiator' && this._streams.initiators.size === (this._init.maxOutboundStreams ?? MAX_STREAMS_OUTBOUND_STREAMS_PER_CONNECTION)) {
|
157
160
|
throw new CodeError('Too many outbound streams open', 'ERR_TOO_MANY_OUTBOUND_STREAMS');
|
158
161
|
}
|
@@ -160,19 +163,19 @@ export class MplexStreamMuxer {
|
|
160
163
|
throw new Error(`${type} stream ${id} already exists!`);
|
161
164
|
}
|
162
165
|
const send = async (msg) => {
|
163
|
-
if (log.enabled) {
|
164
|
-
log.trace('%s stream %s send', type, id, printMessage(msg));
|
166
|
+
if (this.log.enabled) {
|
167
|
+
this.log.trace('%s stream %s send', type, id, printMessage(msg));
|
165
168
|
}
|
166
169
|
this._source.push(msg);
|
167
170
|
};
|
168
171
|
const onEnd = () => {
|
169
|
-
log('%s stream with id %s and protocol %s ended', type, id, stream.protocol);
|
172
|
+
this.log('%s stream with id %s and protocol %s ended', type, id, stream.protocol);
|
170
173
|
registry.delete(id);
|
171
174
|
if (this._init.onStreamEnd != null) {
|
172
175
|
this._init.onStreamEnd(stream);
|
173
176
|
}
|
174
177
|
};
|
175
|
-
const stream = createStream({ id, name, send, type, onEnd, maxMsgSize: this._init.maxMsgSize });
|
178
|
+
const stream = createStream({ id, name, send, type, onEnd, maxMsgSize: this._init.maxMsgSize, logger: this.logger });
|
176
179
|
registry.set(id, stream);
|
177
180
|
return stream;
|
178
181
|
}
|
@@ -182,10 +185,11 @@ export class MplexStreamMuxer {
|
|
182
185
|
*/
|
183
186
|
_createSink() {
|
184
187
|
const sink = async (source) => {
|
188
|
+
const abortListener = () => {
|
189
|
+
closeSource(source, this.log);
|
190
|
+
};
|
191
|
+
this.closeController.signal.addEventListener('abort', abortListener);
|
185
192
|
try {
|
186
|
-
source = abortableSource(source, this.closeController.signal, {
|
187
|
-
returnOnAbort: true
|
188
|
-
});
|
189
193
|
const decoder = new Decoder(this._init.maxMsgSize, this._init.maxUnprocessedMessageQueueSize);
|
190
194
|
for await (const chunk of source) {
|
191
195
|
for (const msg of decoder.write(chunk)) {
|
@@ -195,21 +199,24 @@ export class MplexStreamMuxer {
|
|
195
199
|
this._source.end();
|
196
200
|
}
|
197
201
|
catch (err) {
|
198
|
-
log('error in sink', err);
|
202
|
+
this.log('error in sink', err);
|
199
203
|
this._source.end(err); // End the source with an error
|
200
204
|
}
|
205
|
+
finally {
|
206
|
+
this.closeController.signal.removeEventListener('abort', abortListener);
|
207
|
+
}
|
201
208
|
};
|
202
209
|
return sink;
|
203
210
|
}
|
204
211
|
async _handleIncoming(message) {
|
205
212
|
const { id, type } = message;
|
206
|
-
if (log.enabled) {
|
207
|
-
log.trace('incoming message', printMessage(message));
|
213
|
+
if (this.log.enabled) {
|
214
|
+
this.log.trace('incoming message', printMessage(message));
|
208
215
|
}
|
209
216
|
// Create a new stream?
|
210
217
|
if (message.type === MessageTypes.NEW_STREAM) {
|
211
218
|
if (this._streams.receivers.size === (this._init.maxInboundStreams ?? MAX_STREAMS_INBOUND_STREAMS_PER_CONNECTION)) {
|
212
|
-
log('too many inbound streams open');
|
219
|
+
this.log('too many inbound streams open');
|
213
220
|
// not going to allow this stream, send the reset message manually
|
214
221
|
// instead of setting it up just to tear it down
|
215
222
|
this._source.push({
|
@@ -223,7 +230,7 @@ export class MplexStreamMuxer {
|
|
223
230
|
await this.rateLimiter.consume('new-stream', 1);
|
224
231
|
}
|
225
232
|
catch {
|
226
|
-
log('rate limit hit when opening too many new streams over the inbound stream limit - closing remote connection');
|
233
|
+
this.log('rate limit hit when opening too many new streams over the inbound stream limit - closing remote connection');
|
227
234
|
// since there's no backpressure in mplex, the only thing we can really do to protect ourselves is close the connection
|
228
235
|
this.abort(new Error('Too many open streams'));
|
229
236
|
return;
|
@@ -239,7 +246,7 @@ export class MplexStreamMuxer {
|
|
239
246
|
const list = (type & 1) === 1 ? this._streams.initiators : this._streams.receivers;
|
240
247
|
const stream = list.get(id);
|
241
248
|
if (stream == null) {
|
242
|
-
log('missing stream %s for message type %s', id, MessageTypeNames[type]);
|
249
|
+
this.log('missing stream %s for message type %s', id, MessageTypeNames[type]);
|
243
250
|
// if the remote keeps sending us messages for streams that have been
|
244
251
|
// closed or were never opened they may be attacking us so if they do
|
245
252
|
// this very quickly all we can do is close the connection
|
@@ -247,7 +254,7 @@ export class MplexStreamMuxer {
|
|
247
254
|
await this.rateLimiter.consume('missing-stream', 1);
|
248
255
|
}
|
249
256
|
catch {
|
250
|
-
log('rate limit hit when receiving messages for streams that do not exist - closing remote connection');
|
257
|
+
this.log('rate limit hit when receiving messages for streams that do not exist - closing remote connection');
|
251
258
|
// since there's no backpressure in mplex, the only thing we can really do to protect ourselves is close the connection
|
252
259
|
this.abort(new Error('Too many messages for missing streams'));
|
253
260
|
return;
|
@@ -282,11 +289,11 @@ export class MplexStreamMuxer {
|
|
282
289
|
stream.reset();
|
283
290
|
break;
|
284
291
|
default:
|
285
|
-
log('unknown message type %s', type);
|
292
|
+
this.log('unknown message type %s', type);
|
286
293
|
}
|
287
294
|
}
|
288
295
|
catch (err) {
|
289
|
-
log.error('error while processing message', err);
|
296
|
+
this.log.error('error while processing message', err);
|
290
297
|
stream.abort(err);
|
291
298
|
}
|
292
299
|
}
|
package/dist/src/mplex.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"mplex.js","sourceRoot":"","sources":["../../src/mplex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,
|
1
|
+
{"version":3,"file":"mplex.js","sourceRoot":"","sources":["../../src/mplex.ts"],"names":[],"mapp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AE,CAAA;oBACzB,MAAK;gBACP,KAAK,YAAY,CAAC,eAAe,CAAC;gBAClC,KAAK,YAAY,CAAC,cAAc;oBAC9B,6EAA6E;oBAC7E,MAAM,CAAC,KAAK,EAAE,CAAA;oBACd,MAAK;gBACP;oBACE,IAAI,CAAC,GAAG,CAAC,yBAAyB,EAAE,IAAI,CAAC,CAAA;YAC7C,CAAC;QACH,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,gCAAgC,EAAE,GAAG,CAAC,CAAA;YACrD,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;QACnB,CAAC;IACH,CAAC;CACF"}
|
package/dist/src/stream.d.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
import { AbstractStream, type AbstractStreamInit } from '@libp2p/
|
1
|
+
import { AbstractStream, type AbstractStreamInit } from '@libp2p/utils/abstract-stream';
|
2
2
|
import { Uint8ArrayList } from 'uint8arraylist';
|
3
3
|
import type { Message } from './message-types.js';
|
4
|
+
import type { ComponentLogger } from '@libp2p/interface';
|
4
5
|
export interface Options {
|
5
6
|
id: number;
|
6
7
|
send(msg: Message): Promise<void>;
|
@@ -8,6 +9,7 @@ export interface Options {
|
|
8
9
|
onEnd?(err?: Error): void;
|
9
10
|
type?: 'initiator' | 'receiver';
|
10
11
|
maxMsgSize?: number;
|
12
|
+
logger: ComponentLogger;
|
11
13
|
}
|
12
14
|
interface MplexStreamInit extends AbstractStreamInit {
|
13
15
|
streamId: number;
|
package/dist/src/stream.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,kBAAkB,EAAE,MAAM,
|
1
|
+
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,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AAK,OAAO,CAAC,IAAI,CAAC;IAIhC,aAAa,IAAK,OAAO,CAAC,IAAI,CAAC;CAGtC;AAED,wBAAgB,YAAY,CAAE,OAAO,EAAE,OAAO,GAAG,WAAW,CAa3D"}
|
package/dist/src/stream.js
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
import { AbstractStream } from '@libp2p/
|
2
|
-
import { logger } from '@libp2p/logger';
|
1
|
+
import { AbstractStream } from '@libp2p/utils/abstract-stream';
|
3
2
|
import { Uint8ArrayList } from 'uint8arraylist';
|
4
3
|
import { fromString as uint8ArrayFromString } from 'uint8arrays/from-string';
|
5
4
|
import { MAX_MSG_SIZE } from './decode.js';
|
@@ -53,7 +52,7 @@ export function createStream(options) {
|
|
53
52
|
maxDataSize: maxMsgSize,
|
54
53
|
onEnd,
|
55
54
|
send,
|
56
|
-
log: logger(`libp2p:mplex:stream:${type}:${id}`)
|
55
|
+
log: options.logger.forComponent(`libp2p:mplex:stream:${type}:${id}`)
|
57
56
|
});
|
58
57
|
}
|
59
58
|
//# sourceMappingURL=stream.js.map
|
package/dist/src/stream.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../../src/stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAA2B,MAAM,
|
1
|
+
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../../src/stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAA2B,MAAM,+BAA+B,CAAA;AACvF,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,UAAU,IAAI,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AA0BhF,MAAM,OAAO,WAAY,SAAQ,cAAc;IAC5B,IAAI,CAAQ;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": "10.0.0-551622a96",
|
4
4
|
"description": "JavaScript implementation of https://github.com/libp2p/mplex",
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
6
|
-
"homepage": "https://github.com/libp2p/js-libp2p/tree/
|
6
|
+
"homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/stream-multiplexer-mplex#readme",
|
7
7
|
"repository": {
|
8
8
|
"type": "git",
|
9
9
|
"url": "git+https://github.com/libp2p/js-libp2p.git"
|
@@ -11,6 +11,10 @@
|
|
11
11
|
"bugs": {
|
12
12
|
"url": "https://github.com/libp2p/js-libp2p/issues"
|
13
13
|
},
|
14
|
+
"publishConfig": {
|
15
|
+
"access": "public",
|
16
|
+
"provenance": true
|
17
|
+
},
|
14
18
|
"keywords": [
|
15
19
|
"IPFS",
|
16
20
|
"connection",
|
@@ -57,12 +61,10 @@
|
|
57
61
|
"test:electron-main": "aegir test -t electron-main"
|
58
62
|
},
|
59
63
|
"dependencies": {
|
60
|
-
"@libp2p/interface": "
|
61
|
-
"@libp2p/
|
62
|
-
"abortable-iterator": "^5.0.1",
|
64
|
+
"@libp2p/interface": "1.0.0-551622a96",
|
65
|
+
"@libp2p/utils": "5.0.0-551622a96",
|
63
66
|
"benchmark": "^2.1.4",
|
64
|
-
"it-
|
65
|
-
"it-pushable": "^3.2.0",
|
67
|
+
"it-pushable": "^3.2.1",
|
66
68
|
"it-stream-types": "^2.0.1",
|
67
69
|
"rate-limiter-flexible": "^3.0.0",
|
68
70
|
"uint8-varint": "^2.0.0",
|
@@ -70,17 +72,18 @@
|
|
70
72
|
"uint8arrays": "^4.0.6"
|
71
73
|
},
|
72
74
|
"devDependencies": {
|
73
|
-
"@libp2p/interface-compliance-tests": "
|
75
|
+
"@libp2p/interface-compliance-tests": "5.0.0-551622a96",
|
76
|
+
"@libp2p/logger": "4.0.0-551622a96",
|
74
77
|
"aegir": "^41.0.2",
|
75
78
|
"cborg": "^4.0.3",
|
76
79
|
"delay": "^6.0.0",
|
77
80
|
"iso-random-stream": "^2.0.2",
|
78
|
-
"it-all": "^3.0.
|
79
|
-
"it-drain": "^3.0.
|
81
|
+
"it-all": "^3.0.3",
|
82
|
+
"it-drain": "^3.0.3",
|
80
83
|
"it-foreach": "^2.0.2",
|
81
84
|
"it-map": "^3.0.3",
|
85
|
+
"it-pair": "^2.0.6",
|
82
86
|
"it-pipe": "^3.0.1",
|
83
|
-
"it-to-buffer": "^4.0.1",
|
84
87
|
"p-defer": "^4.0.0",
|
85
88
|
"random-int": "^3.0.0"
|
86
89
|
},
|
package/src/encode.ts
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
import batchedBytes from 'it-batched-bytes'
|
2
1
|
import * as varint from 'uint8-varint'
|
3
2
|
import { Uint8ArrayList } from 'uint8arraylist'
|
4
3
|
import { allocUnsafe } from './alloc-unsafe.js'
|
@@ -56,29 +55,10 @@ const encoder = new Encoder()
|
|
56
55
|
/**
|
57
56
|
* Encode and yield one or more messages
|
58
57
|
*/
|
59
|
-
export async function * encode (source: Source<Message
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
for (const msg of messages) {
|
66
|
-
encoder.write(msg, list)
|
67
|
-
}
|
68
|
-
|
69
|
-
yield list.subarray()
|
70
|
-
}
|
71
|
-
|
72
|
-
return
|
58
|
+
export async function * encode (source: Source<Message>): AsyncGenerator<Uint8Array | Uint8ArrayList, void, undefined> {
|
59
|
+
for await (const message of source) {
|
60
|
+
const list = new Uint8ArrayList()
|
61
|
+
encoder.write(message, list)
|
62
|
+
yield list
|
73
63
|
}
|
74
|
-
|
75
|
-
// batch messages up for sending
|
76
|
-
yield * batchedBytes(source, {
|
77
|
-
size: minSendBytes,
|
78
|
-
serialize: (obj, list) => {
|
79
|
-
for (const m of obj) {
|
80
|
-
encoder.write(m, list)
|
81
|
-
}
|
82
|
-
}
|
83
|
-
})
|
84
64
|
}
|
package/src/index.ts
CHANGED
@@ -32,7 +32,7 @@
|
|
32
32
|
*/
|
33
33
|
|
34
34
|
import { MplexStreamMuxer } from './mplex.js'
|
35
|
-
import type { StreamMuxer, StreamMuxerFactory, StreamMuxerInit } from '@libp2p/interface
|
35
|
+
import type { ComponentLogger, StreamMuxer, StreamMuxerFactory, StreamMuxerInit } from '@libp2p/interface'
|
36
36
|
|
37
37
|
export interface MplexInit {
|
38
38
|
/**
|
@@ -52,18 +52,6 @@ export interface MplexInit {
|
|
52
52
|
*/
|
53
53
|
maxUnprocessedMessageQueueSize?: number
|
54
54
|
|
55
|
-
/**
|
56
|
-
* Each byte array written into a multiplexed stream is converted to one or
|
57
|
-
* more messages which are sent as byte arrays to the remote node. Sending
|
58
|
-
* lots of small messages can be expensive - use this setting to batch up
|
59
|
-
* the serialized bytes of all messages sent during the current tick up to
|
60
|
-
* this limit to send in one go similar to Nagle's algorithm. N.b. you
|
61
|
-
* should benchmark your application carefully when using this setting as it
|
62
|
-
* may cause the opposite of the desired effect. Omit this setting to send
|
63
|
-
* all messages as they become available. (default: undefined)
|
64
|
-
*/
|
65
|
-
minSendBytes?: number
|
66
|
-
|
67
55
|
/**
|
68
56
|
* The maximum number of multiplexed streams that can be open at any
|
69
57
|
* one time. A request to open more than this will have a stream
|
@@ -96,19 +84,25 @@ export interface MplexInit {
|
|
96
84
|
class Mplex implements StreamMuxerFactory {
|
97
85
|
public protocol = '/mplex/6.7.0'
|
98
86
|
private readonly _init: MplexInit
|
87
|
+
private readonly components: MplexComponents
|
99
88
|
|
100
|
-
constructor (init: MplexInit = {}) {
|
89
|
+
constructor (components: MplexComponents, init: MplexInit = {}) {
|
90
|
+
this.components = components
|
101
91
|
this._init = init
|
102
92
|
}
|
103
93
|
|
104
94
|
createStreamMuxer (init: StreamMuxerInit = {}): StreamMuxer {
|
105
|
-
return new MplexStreamMuxer({
|
95
|
+
return new MplexStreamMuxer(this.components, {
|
106
96
|
...init,
|
107
97
|
...this._init
|
108
98
|
})
|
109
99
|
}
|
110
100
|
}
|
111
101
|
|
112
|
-
export
|
113
|
-
|
102
|
+
export interface MplexComponents {
|
103
|
+
logger: ComponentLogger
|
104
|
+
}
|
105
|
+
|
106
|
+
export function mplex (init: MplexInit = {}): (components: MplexComponents) => StreamMuxerFactory {
|
107
|
+
return (components) => new Mplex(components, init)
|
114
108
|
}
|