@dxos/hypercore 0.1.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.
Files changed (73) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +4 -0
  3. package/dist/src/crypto.d.ts +13 -0
  4. package/dist/src/crypto.d.ts.map +1 -0
  5. package/dist/src/crypto.js +45 -0
  6. package/dist/src/crypto.js.map +1 -0
  7. package/dist/src/defaults.d.ts +18 -0
  8. package/dist/src/defaults.d.ts.map +1 -0
  9. package/dist/src/defaults.js +44 -0
  10. package/dist/src/defaults.js.map +1 -0
  11. package/dist/src/hypercore-factory.d.ts +23 -0
  12. package/dist/src/hypercore-factory.d.ts.map +1 -0
  13. package/dist/src/hypercore-factory.js +44 -0
  14. package/dist/src/hypercore-factory.js.map +1 -0
  15. package/dist/src/hypercore-factory.test.d.ts +2 -0
  16. package/dist/src/hypercore-factory.test.d.ts.map +1 -0
  17. package/dist/src/hypercore-factory.test.js +46 -0
  18. package/dist/src/hypercore-factory.test.js.map +1 -0
  19. package/dist/src/hypercore-protocol.test.d.ts +2 -0
  20. package/dist/src/hypercore-protocol.test.d.ts.map +1 -0
  21. package/dist/src/hypercore-protocol.test.js +191 -0
  22. package/dist/src/hypercore-protocol.test.js.map +1 -0
  23. package/dist/src/hypercore.test.d.ts +2 -0
  24. package/dist/src/hypercore.test.d.ts.map +1 -0
  25. package/dist/src/hypercore.test.js +79 -0
  26. package/dist/src/hypercore.test.js.map +1 -0
  27. package/dist/src/index.d.ts +5 -0
  28. package/dist/src/index.d.ts.map +1 -0
  29. package/dist/src/index.js +24 -0
  30. package/dist/src/index.js.map +1 -0
  31. package/dist/src/iterator.d.ts +26 -0
  32. package/dist/src/iterator.d.ts.map +1 -0
  33. package/dist/src/iterator.js +37 -0
  34. package/dist/src/iterator.js.map +1 -0
  35. package/dist/src/iterator.test.d.ts +2 -0
  36. package/dist/src/iterator.test.d.ts.map +1 -0
  37. package/dist/src/iterator.test.js +61 -0
  38. package/dist/src/iterator.test.js.map +1 -0
  39. package/dist/src/multiplexer.d.ts +21 -0
  40. package/dist/src/multiplexer.d.ts.map +1 -0
  41. package/dist/src/multiplexer.js +103 -0
  42. package/dist/src/multiplexer.js.map +1 -0
  43. package/dist/src/multiplexer.test.d.ts +2 -0
  44. package/dist/src/multiplexer.test.d.ts.map +1 -0
  45. package/dist/src/multiplexer.test.js +142 -0
  46. package/dist/src/multiplexer.test.js.map +1 -0
  47. package/dist/src/replicate.test.d.ts +2 -0
  48. package/dist/src/replicate.test.d.ts.map +1 -0
  49. package/dist/src/replicate.test.js +197 -0
  50. package/dist/src/replicate.test.js.map +1 -0
  51. package/dist/src/streams.test.d.ts +2 -0
  52. package/dist/src/streams.test.d.ts.map +1 -0
  53. package/dist/src/streams.test.js +65 -0
  54. package/dist/src/streams.test.js.map +1 -0
  55. package/dist/src/testing.d.ts +11 -0
  56. package/dist/src/testing.d.ts.map +1 -0
  57. package/dist/src/testing.js +36 -0
  58. package/dist/src/testing.js.map +1 -0
  59. package/package.json +50 -0
  60. package/src/crypto.ts +46 -0
  61. package/src/defaults.ts +46 -0
  62. package/src/hypercore-factory.test.ts +53 -0
  63. package/src/hypercore-factory.ts +44 -0
  64. package/src/hypercore-protocol.test.ts +236 -0
  65. package/src/hypercore.test.ts +98 -0
  66. package/src/index.ts +8 -0
  67. package/src/iterator.test.ts +66 -0
  68. package/src/iterator.ts +35 -0
  69. package/src/multiplexer.test.ts +172 -0
  70. package/src/multiplexer.ts +122 -0
  71. package/src/replicate.test.ts +241 -0
  72. package/src/streams.test.ts +75 -0
  73. package/src/testing.ts +40 -0
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ //
3
+ // Copyright 2021 DXOS.org
4
+ //
5
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ var desc = Object.getOwnPropertyDescriptor(m, k);
8
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
+ desc = { enumerable: true, get: function() { return m[k]; } };
10
+ }
11
+ Object.defineProperty(o, k2, desc);
12
+ }) : (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ o[k2] = m[k];
15
+ }));
16
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
17
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ __exportStar(require("./crypto"), exports);
21
+ __exportStar(require("./defaults"), exports);
22
+ __exportStar(require("./hypercore-factory"), exports);
23
+ __exportStar(require("./iterator"), exports);
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;;;;;;;;;;;;;;;;AAEF,2CAAyB;AACzB,6CAA2B;AAC3B,sDAAoC;AACpC,6CAA2B"}
@@ -0,0 +1,26 @@
1
+ import { Readable } from 'readable-stream';
2
+ import { Readable as StreamXReadable } from 'streamx';
3
+ /**
4
+ * Wraps streamx.Readable (hypercore.createReadStream) to a standard Readable stream.
5
+ *
6
+ * The read-stream package is mirror of the streams implementations in Node.js 18.9.0.
7
+ * This function is here to standardize the cast in case there are incompatibilities
8
+ * across different platforms.
9
+ *
10
+ * Hypercore createReadStream returns a `streamx` Readable, which does not close properly on destroy.
11
+ *
12
+ * https://github.com/nodejs/readable-stream
13
+ * https://nodejs.org/api/stream.html#readable-streams
14
+ * https://nodejs.org/dist/v18.9.0/docs/api/stream.html#readablewrapstream
15
+ */
16
+ export declare const createReadable: (stream: StreamXReadable) => Readable;
17
+ /**
18
+ * Converts streamx.Readable (hypercore.createReadStream) to an async iterator.
19
+ *
20
+ * https://github.com/tc39/proposal-async-iteration
21
+ * https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-3.html#async-iteration
22
+ * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators
23
+ * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols
24
+ */
25
+ export declare const createAsyncIterator: (stream: Readable) => AsyncIterator<any>;
26
+ //# sourceMappingURL=iterator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iterator.d.ts","sourceRoot":"","sources":["../../src/iterator.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,QAAQ,IAAI,eAAe,EAAE,MAAM,SAAS,CAAC;AAEtD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,cAAc,WAAY,eAAe,KAAG,QAExD,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,WAAY,QAAQ,KAAG,cAAc,GAAG,CAEvE,CAAC"}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ //
3
+ // Copyright 2022 DXOS.org
4
+ //
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.createAsyncIterator = exports.createReadable = void 0;
7
+ const readable_stream_1 = require("readable-stream");
8
+ /**
9
+ * Wraps streamx.Readable (hypercore.createReadStream) to a standard Readable stream.
10
+ *
11
+ * The read-stream package is mirror of the streams implementations in Node.js 18.9.0.
12
+ * This function is here to standardize the cast in case there are incompatibilities
13
+ * across different platforms.
14
+ *
15
+ * Hypercore createReadStream returns a `streamx` Readable, which does not close properly on destroy.
16
+ *
17
+ * https://github.com/nodejs/readable-stream
18
+ * https://nodejs.org/api/stream.html#readable-streams
19
+ * https://nodejs.org/dist/v18.9.0/docs/api/stream.html#readablewrapstream
20
+ */
21
+ const createReadable = (stream) => {
22
+ return new readable_stream_1.Readable({ objectMode: true }).wrap(stream);
23
+ };
24
+ exports.createReadable = createReadable;
25
+ /**
26
+ * Converts streamx.Readable (hypercore.createReadStream) to an async iterator.
27
+ *
28
+ * https://github.com/tc39/proposal-async-iteration
29
+ * https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-3.html#async-iteration
30
+ * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators
31
+ * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols
32
+ */
33
+ const createAsyncIterator = (stream) => {
34
+ return stream[Symbol.asyncIterator]();
35
+ };
36
+ exports.createAsyncIterator = createAsyncIterator;
37
+ //# sourceMappingURL=iterator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iterator.js","sourceRoot":"","sources":["../../src/iterator.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;;;AAEF,qDAA2C;AAG3C;;;;;;;;;;;;GAYG;AACI,MAAM,cAAc,GAAG,CAAC,MAAuB,EAAY,EAAE;IAClE,OAAO,IAAI,0BAAQ,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,MAAa,CAAC,CAAC;AAChE,CAAC,CAAC;AAFW,QAAA,cAAc,kBAEzB;AAEF;;;;;;;GAOG;AACI,MAAM,mBAAmB,GAAG,CAAC,MAAgB,EAAsB,EAAE;IAC1E,OAAO,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,CAAC;AACxC,CAAC,CAAC;AAFW,QAAA,mBAAmB,uBAE9B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=iterator.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iterator.test.d.ts","sourceRoot":"","sources":["../../src/iterator.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ //
3
+ // Copyright 2019 DXOS.org
4
+ //
5
+ var __importDefault = (this && this.__importDefault) || function (mod) {
6
+ return (mod && mod.__esModule) ? mod : { "default": mod };
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ const node_util_1 = __importDefault(require("node:util"));
10
+ const async_1 = require("@dxos/async");
11
+ const crypto_1 = require("@dxos/crypto");
12
+ const log_1 = require("@dxos/log");
13
+ const hypercore_factory_1 = require("./hypercore-factory");
14
+ const iterator_1 = require("./iterator");
15
+ describe('AsyncIterator', function () {
16
+ it('iterates a feed until stopped', async function () {
17
+ const factory = new hypercore_factory_1.HypercoreFactory();
18
+ const { publicKey, secretKey } = (0, crypto_1.createKeyPair)();
19
+ const core = factory.createFeed(publicKey, { secretKey });
20
+ const numBlocks = 10;
21
+ // Write.
22
+ {
23
+ const append = node_util_1.default.promisify(core.append.bind(core));
24
+ for (let i = 0; i < numBlocks; i++) {
25
+ await append(`test-${i}`);
26
+ }
27
+ }
28
+ // Read until stopped.
29
+ {
30
+ // Read forever.
31
+ // NOTE: Read must be opened in live mode.
32
+ // NOTE: Uses wrapper to normalize stream; otherwise done isn't called after destroying the stream.
33
+ const stream = (0, iterator_1.createReadable)(core.createReadStream({ live: true }));
34
+ // Use util to create reliable iterators.
35
+ const iterator = (0, iterator_1.createAsyncIterator)(stream);
36
+ const [streamEnded, end] = (0, async_1.latch)();
37
+ const [readAll, inc] = (0, async_1.latch)({ count: numBlocks });
38
+ setTimeout(async () => {
39
+ while (true) {
40
+ try {
41
+ const { value, done } = await iterator.next();
42
+ if (done) {
43
+ end();
44
+ break;
45
+ }
46
+ (0, log_1.log)('received', { data: String(value) }, { file: "packages/common/hypercore/src/iterator.test.ts", line: 51 });
47
+ inc();
48
+ }
49
+ catch (err) {
50
+ end();
51
+ break;
52
+ }
53
+ }
54
+ });
55
+ await readAll();
56
+ stream.destroy();
57
+ await streamEnded();
58
+ }
59
+ });
60
+ });
61
+ //# sourceMappingURL=iterator.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iterator.test.js","sourceRoot":"","sources":["../../src/iterator.test.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;;;;;AAEF,0DAA6B;AAE7B,uCAAoC;AACpC,yCAA6C;AAC7C,mCAAgC;AAEh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,IAAI,IAAI,EAAE;4BACR,GAAG,EAAE,CAAC;4BACN,MAAM;yBACP;wBAED,IAAA,SAAG,EAAC,UAAU,EAAE,EAAE,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,uEAAC,CAAC;wBACzC,GAAG,EAAE,CAAC;qBACP;oBAAC,OAAO,GAAG,EAAE;wBACZ,GAAG,EAAE,CAAC;wBACN,MAAM;qBACP;iBACF;YACH,CAAC,CAAC,CAAC;YAEH,MAAM,OAAO,EAAE,CAAC;YAEhB,MAAM,CAAC,OAAO,EAAE,CAAC;YACjB,MAAM,WAAW,EAAE,CAAC;SACrB;IACH,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { Hypercore } from 'hypercore';
2
+ import { PassThrough } from 'streamx';
3
+ /**
4
+ * Hypercore multiplexer.
5
+ */
6
+ export declare class Multiplexer {
7
+ private readonly _id;
8
+ private readonly _feeds;
9
+ private readonly _streams;
10
+ private _isOpen;
11
+ private _closedTrigger;
12
+ readonly input: PassThrough;
13
+ readonly output: PassThrough;
14
+ constructor(_id: string);
15
+ get isOpen(): boolean;
16
+ get feeds(): Hypercore<any>[];
17
+ addFeed(core: Hypercore, initiator?: boolean): this;
18
+ open(): Promise<void>;
19
+ close(): Promise<void>;
20
+ }
21
+ //# sourceMappingURL=multiplexer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multiplexer.d.ts","sourceRoot":"","sources":["../../src/multiplexer.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,OAAO,EAAE,WAAW,EAAuB,MAAM,SAAS,CAAC;AAO3D;;GAEG;AAEH,qBAAa,WAAW;IAYpB,OAAO,CAAC,QAAQ,CAAC,GAAG;IAXtB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwD;IAC/E,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA6D;IAEtF,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,cAAc,CAAoC;IAE1D,SAAgB,KAAK,cAAqB;IAC1C,SAAgB,MAAM,cAAqB;gBAIxB,GAAG,EAAE,MAAM;IAG9B,IAAI,MAAM,YAET;IAED,IAAI,KAAK,qBAER;IAED,OAAO,CAAC,IAAI,EAAE,SAAS,EAAE,SAAS,UAAQ;IA6BpC,IAAI;IAuBJ,KAAK;CA4BZ"}
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ //
3
+ // Copyright 2022 DXOS.org
4
+ //
5
+ var __importDefault = (this && this.__importDefault) || function (mod) {
6
+ return (mod && mod.__esModule) ? mod : { "default": mod };
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.Multiplexer = void 0;
10
+ const assert_1 = __importDefault(require("assert"));
11
+ const streamx_1 = require("streamx");
12
+ const async_1 = require("@dxos/async");
13
+ const keys_1 = require("@dxos/keys");
14
+ const log_1 = require("@dxos/log");
15
+ const util_1 = require("@dxos/util");
16
+ /**
17
+ * Hypercore multiplexer.
18
+ */
19
+ // TODO(burdon): Add encoding.
20
+ class Multiplexer {
21
+ // prettier-ignore
22
+ constructor(_id) {
23
+ this._id = _id;
24
+ this._feeds = new util_1.ComplexMap(keys_1.PublicKey.hash);
25
+ this._streams = new util_1.ComplexMap(keys_1.PublicKey.hash);
26
+ this._isOpen = false;
27
+ this._closedTrigger = new async_1.Trigger({ autoReset: true });
28
+ this.input = new streamx_1.PassThrough();
29
+ this.output = new streamx_1.PassThrough();
30
+ }
31
+ get isOpen() {
32
+ return this._isOpen;
33
+ }
34
+ get feeds() {
35
+ return Array.from(this._feeds.values());
36
+ }
37
+ addFeed(core, initiator = false) {
38
+ const stream = core.replicate(initiator, { live: true });
39
+ const feedKey = keys_1.PublicKey.from(core.key);
40
+ this._feeds.set(feedKey, core);
41
+ this._streams.set(feedKey, stream);
42
+ (0, log_1.log)('added', { feedKey: keys_1.PublicKey.from(feedKey) }, { file: "packages/common/hypercore/src/multiplexer.ts", line: 48 });
43
+ stream
44
+ .pipe(new streamx_1.Transform({
45
+ transform: (data, next) => {
46
+ (0, log_1.log)('send', { id: this._id, feedKey: keys_1.PublicKey.from(feedKey), payload: data.length }, { file: "packages/common/hypercore/src/multiplexer.ts", line: 54 });
47
+ next(null, {
48
+ feedKey: core.key,
49
+ payload: data
50
+ });
51
+ }
52
+ }))
53
+ .pipe(this.output, () => {
54
+ (0, log_1.log)('pipeline closed', { id: this._id }, { file: "packages/common/hypercore/src/multiplexer.ts", line: 63 });
55
+ this._isOpen = false;
56
+ this._closedTrigger.wake();
57
+ });
58
+ return this;
59
+ }
60
+ async open() {
61
+ if (this._isOpen) {
62
+ return;
63
+ }
64
+ this.input.pipe(new streamx_1.Writable({
65
+ write: (data, next) => {
66
+ const { feedKey, payload } = data;
67
+ const feedStream = this._streams.get(keys_1.PublicKey.from(feedKey));
68
+ (0, assert_1.default)(feedStream, `invalid stream: ${keys_1.PublicKey.from(feedKey).truncate()}`);
69
+ (0, log_1.log)('recv', { id: this._id, feedKey: keys_1.PublicKey.from(feedKey), payload: payload.length }, { file: "packages/common/hypercore/src/multiplexer.ts", line: 82 });
70
+ feedStream.write(payload);
71
+ next();
72
+ }
73
+ }));
74
+ (0, log_1.log)('opened', {}, { file: "packages/common/hypercore/src/multiplexer.ts", line: 89 });
75
+ this._isOpen = true;
76
+ }
77
+ // TODO(burdon): Test if re-entrant?
78
+ async close() {
79
+ if (!this._isOpen) {
80
+ return;
81
+ }
82
+ (0, log_1.log)('closing...', {}, { file: "packages/common/hypercore/src/multiplexer.ts", line: 99 });
83
+ const [closed, setClosed] = (0, async_1.latch)({ count: this._streams.size });
84
+ Array.from(this._streams.values()).forEach((stream) => {
85
+ stream.once('end', () => {
86
+ (0, log_1.log)('stream closed', {}, { file: "packages/common/hypercore/src/multiplexer.ts", line: 103 });
87
+ setClosed();
88
+ });
89
+ stream.finalize();
90
+ });
91
+ await closed();
92
+ // NOTE: Depending on environment, pipeline may close before or after the stream above.
93
+ if (this._isOpen) {
94
+ await this._closedTrigger.wait();
95
+ (0, assert_1.default)(!this._isOpen);
96
+ }
97
+ this._feeds.clear();
98
+ this._streams.clear();
99
+ (0, log_1.log)('closed', {}, { file: "packages/common/hypercore/src/multiplexer.ts", line: 120 });
100
+ }
101
+ }
102
+ exports.Multiplexer = Multiplexer;
103
+ //# sourceMappingURL=multiplexer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multiplexer.js","sourceRoot":"","sources":["../../src/multiplexer.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;;;;;;AAEF,oDAA4B;AAG5B,qCAA2D;AAE3D,uCAA6C;AAC7C,qCAAuC;AACvC,mCAAgC;AAChC,qCAAwC;AAExC;;GAEG;AACH,8BAA8B;AAC9B,MAAa,WAAW;IAUtB,kBAAkB;IAClB,YACmB,GAAW;QAAX,QAAG,GAAH,GAAG,CAAQ;QAXb,WAAM,GAAG,IAAI,iBAAU,CAAuB,gBAAS,CAAC,IAAI,CAAC,CAAC;QAC9D,aAAQ,GAAG,IAAI,iBAAU,CAA4B,gBAAS,CAAC,IAAI,CAAC,CAAC;QAE9E,YAAO,GAAG,KAAK,CAAC;QAChB,mBAAc,GAAG,IAAI,eAAO,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAE1C,UAAK,GAAG,IAAI,qBAAW,EAAE,CAAC;QAC1B,WAAM,GAAG,IAAI,qBAAW,EAAE,CAAC;IAKxC,CAAC;IAEJ,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,IAAI,KAAK;QACP,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IAC1C,CAAC;IAED,OAAO,CAAC,IAAe,EAAE,SAAS,GAAG,KAAK;QACxC,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,IAAI,EAA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AE,CAAC;YACd,CAAC,CAAC,CAAC;YAEH,MAAM,CAAC,QAAQ,EAAE,CAAC;QACpB,CAAC,CAAC,CAAC;QAEH,MAAM,MAAM,EAAE,CAAC;QAEf,uFAAuF;QACvF,IAAI,IAAI,CAAC,OAAO,EAAE;YAChB,MAAM,IAAI,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC;YACjC,IAAA,gBAAM,EAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;SACvB;QAED,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QACpB,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QACtB,IAAA,SAAG,EAAC,QAAQ,0EAAC,CAAC;IAChB,CAAC;CACF;AAvGD,kCAuGC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=multiplexer.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multiplexer.test.d.ts","sourceRoot":"","sources":["../../src/multiplexer.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,142 @@
1
+ "use strict";
2
+ //
3
+ // Copyright 2022 DXOS.org
4
+ //
5
+ var __importDefault = (this && this.__importDefault) || function (mod) {
6
+ return (mod && mod.__esModule) ? mod : { "default": mod };
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ const chai_1 = require("chai");
10
+ const faker_1 = __importDefault(require("faker"));
11
+ const streamx_1 = require("streamx");
12
+ const async_1 = require("@dxos/async");
13
+ const crypto_1 = require("@dxos/crypto");
14
+ const keys_1 = require("@dxos/keys");
15
+ const log_1 = require("@dxos/log");
16
+ const hypercore_factory_1 = require("./hypercore-factory");
17
+ const multiplexer_1 = require("./multiplexer");
18
+ const testing_1 = require("./testing");
19
+ describe('Multiplexing', function () {
20
+ it.only('multiplexes feeds', async function () {
21
+ const plex1 = new multiplexer_1.Multiplexer('A');
22
+ const plex2 = new multiplexer_1.Multiplexer('B');
23
+ await plex1.open();
24
+ await plex2.open();
25
+ const numFeeds = 1;
26
+ const factory = new hypercore_factory_1.HypercoreFactory();
27
+ const feeds = await Promise.all(Array.from(Array(numFeeds)).map(async () => {
28
+ const { publicKey, secretKey } = (0, crypto_1.createKeyPair)();
29
+ const core1 = factory.createFeed(publicKey, { secretKey });
30
+ const core2 = factory.createFeed(publicKey);
31
+ await (0, testing_1.py)(core1, core1.open)();
32
+ await (0, testing_1.py)(core2, core2.open)();
33
+ plex1.addFeed(core1, true);
34
+ plex2.addFeed(core2);
35
+ return [core1, core2];
36
+ }));
37
+ feeds.forEach(([core1, core2]) => {
38
+ (0, chai_1.expect)(core1.stats.peers.length).to.eq(1);
39
+ (0, chai_1.expect)(core2.stats.peers.length).to.eq(1);
40
+ });
41
+ const [closed, setClosed] = (0, async_1.latch)({ count: 2 });
42
+ // TODO(burdon): Test with additional PassThrough.
43
+ plex1.output.pipe(plex2.input, setClosed);
44
+ plex2.output.pipe(plex1.input, setClosed);
45
+ const numMessages = 1;
46
+ const written = new Set();
47
+ Array.from(Array(numMessages)).forEach((_, i) => {
48
+ const [core] = faker_1.default.random.arrayElement(feeds);
49
+ written.add(core.key.toString());
50
+ core.append(`test-${i}: ${faker_1.default.lorem.sentence(10)}`, testing_1.noop); // Long message.
51
+ });
52
+ {
53
+ const [synced, setSynced] = (0, async_1.latch)({ count: written.size });
54
+ feeds.forEach(([, core2]) => {
55
+ core2.on('sync', () => {
56
+ (0, log_1.log)('sync', { feedKey: keys_1.PublicKey.from(core2.key) }, { file: "packages/common/hypercore/src/multiplexer.test.ts", line: 66 });
57
+ setSynced();
58
+ });
59
+ });
60
+ await synced();
61
+ }
62
+ await plex1.close();
63
+ await plex2.close();
64
+ await closed();
65
+ (0, chai_1.expect)(plex1.isOpen).to.be.false;
66
+ (0, chai_1.expect)(plex2.isOpen).to.be.false;
67
+ const count = feeds.reduce((total, [, core2]) => total + core2.length, 0);
68
+ (0, chai_1.expect)(count).to.eq(numMessages);
69
+ });
70
+ it('pipelines', async function () {
71
+ const factory = new hypercore_factory_1.HypercoreFactory();
72
+ const { publicKey, secretKey } = (0, crypto_1.createKeyPair)();
73
+ const core1 = factory.createFeed(publicKey, { secretKey });
74
+ const core2 = factory.createFeed(publicKey);
75
+ await (0, testing_1.py)(core1, core1.open)();
76
+ await (0, testing_1.py)(core2, core2.open)();
77
+ const stream1 = core1.replicate(true, { live: true });
78
+ const stream2 = core2.replicate(false, { live: true });
79
+ //
80
+ // Pipeline
81
+ //
82
+ const createWireTap = (label) => new streamx_1.Transform({
83
+ transform: (data, next) => {
84
+ (0, log_1.log)(label, { length: data.length }, { file: "packages/common/hypercore/src/multiplexer.test.ts", line: 104 });
85
+ next(null, data);
86
+ }
87
+ });
88
+ const [pipelineClosed, onStreamClose] = (0, async_1.latch)({ count: 2 });
89
+ const createPipeline = (type) => {
90
+ switch (type) {
91
+ case 1:
92
+ // prettier-ignore
93
+ return stream1
94
+ .pipe(stream2, onStreamClose)
95
+ .pipe(stream1, onStreamClose);
96
+ case 2:
97
+ // prettier-ignore
98
+ return stream1
99
+ .pipe(new streamx_1.PassThrough())
100
+ .pipe(stream2, onStreamClose)
101
+ .pipe(new streamx_1.PassThrough())
102
+ .pipe(stream1, onStreamClose);
103
+ case 3:
104
+ // prettier-ignore
105
+ return stream1
106
+ .pipe(createWireTap('send'))
107
+ .pipe(stream2, onStreamClose)
108
+ .pipe(createWireTap('recv'))
109
+ .pipe(stream1, onStreamClose);
110
+ }
111
+ };
112
+ const pipeline = createPipeline(3);
113
+ (0, chai_1.expect)(core1.stats.peers).to.have.lengthOf(1);
114
+ (0, chai_1.expect)(core2.stats.peers).to.have.lengthOf(1);
115
+ //
116
+ // Sync
117
+ //
118
+ const numMessages = 10;
119
+ const [synced, setSynced] = (0, async_1.latch)();
120
+ core2.on('sync', () => {
121
+ (0, log_1.log)('sync', { send: core1.stats.totals, recv: core1.stats.totals }, { file: "packages/common/hypercore/src/multiplexer.test.ts", line: 147 });
122
+ (0, chai_1.expect)(core2.length).to.eq(10);
123
+ setSynced();
124
+ });
125
+ Array.from(Array(numMessages)).map((_, i) => core1.append(`test-${i}: ${faker_1.default.lorem.sentence()}`, testing_1.noop));
126
+ await synced();
127
+ //
128
+ // Close
129
+ //
130
+ {
131
+ pipeline.finalize();
132
+ await pipelineClosed();
133
+ const [feedsClosed, done] = (0, async_1.latch)({ count: 2 });
134
+ core1.close(done);
135
+ core2.close(done);
136
+ await feedsClosed();
137
+ (0, chai_1.expect)(core1.closed).to.be.true;
138
+ (0, chai_1.expect)(core2.closed).to.be.true;
139
+ }
140
+ });
141
+ });
142
+ //# sourceMappingURL=multiplexer.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multiplexer.test.js","sourceRoot":"","sources":["../../src/multiplexer.test.ts"],"names":[],"mappings":";AAAA,EAAE;AACF,0BAA0B;AAC1B,EAAE;;;;;AAEF,+BAA8B;AAC9B,kDAA0B;AAC1B,qCAAiD;AAEjD,uCAAoC;AACpC,yCAA6C;AAC7C,qCAAuC;AACvC,mCAAgC;AAEhC,2DAAuD;AACvD,+CAA4C;AAC5C,uCAAqC;AAErC,QAAQ,CAAC,cAAc,EAAE;IACvB,EAAE,CAAC,IAAI,CAAC,mBAAmB,EAAE,KAAK;QAChC,MAAM,KAAK,GAAG,IAAI,yBAAW,CAAC,GAAG,CAAC,CAAC;QACnC,MAAM,KAAK,GAAG,IAAI,yBAAW,CAAC,GAAG,CAAC,CAAC;QAEnC,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC;QAEnB,MAAM,QAAQ,GAAG,CAAC,CAAC;QACnB,MAAM,OAAO,GAAG,IAAI,oCAAgB,EAAE,CAAC;QACvC,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,GAAG,CAC7B,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE;YACzC,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,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