@dxos/network-manager 0.1.32-next.86f5578 → 0.1.34
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/lib/browser/{chunk-ELRPGOK3.mjs → chunk-4W77MFHZ.mjs} +191 -95
- package/dist/lib/browser/chunk-4W77MFHZ.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +1 -1
- package/dist/lib/node/index.cjs +193 -97
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +201 -105
- package/dist/lib/node/testing/index.cjs.map +3 -3
- package/dist/types/src/network-manager.d.ts +1 -0
- package/dist/types/src/network-manager.d.ts.map +1 -1
- package/dist/types/src/swarm/connection.d.ts +5 -0
- package/dist/types/src/swarm/connection.d.ts.map +1 -1
- package/dist/types/src/swarm/peer.d.ts +1 -0
- package/dist/types/src/swarm/peer.d.ts.map +1 -1
- package/dist/types/src/swarm/swarm.d.ts +1 -1
- package/dist/types/src/swarm/swarm.d.ts.map +1 -1
- package/dist/types/src/transport/webrtc-transport.d.ts +2 -0
- package/dist/types/src/transport/webrtc-transport.d.ts.map +1 -1
- package/package.json +16 -16
- package/src/connection-log.ts +3 -3
- package/src/network-manager.ts +6 -0
- package/src/swarm/connection.ts +13 -1
- package/src/swarm/peer.ts +3 -0
- package/src/swarm/swarm.ts +9 -1
- package/src/transport/webrtc-transport.ts +13 -0
- package/dist/lib/browser/chunk-ELRPGOK3.mjs.map +0 -7
|
@@ -55,6 +55,7 @@ export declare class NetworkManager {
|
|
|
55
55
|
readonly connectionStateChanged: Event<ConnectionState>;
|
|
56
56
|
private readonly _connectionLog?;
|
|
57
57
|
readonly topicsUpdated: Event<void>;
|
|
58
|
+
private readonly _instanceId;
|
|
58
59
|
constructor({ transportFactory, signalManager, log }: NetworkManagerOptions);
|
|
59
60
|
get connectionLog(): ConnectionLog | undefined;
|
|
60
61
|
get signalManager(): SignalManager;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network-manager.d.ts","sourceRoot":"","sources":["../../../src/network-manager.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAa,aAAa,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"network-manager.d.ts","sourceRoot":"","sources":["../../../src/network-manager.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAa,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE3D,OAAO,EAAE,eAAe,EAAE,MAAM,4CAA4C,CAAC;AAG7E,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAEvD;;GAEG;AACH,oBAAY,eAAe,GAAG;IAC5B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB,CAAC;AAGF,oBAAY,YAAY,GAAG;IACzB;;OAEG;IACH,KAAK,EAAE,SAAS,CAAC;IAEjB;;OAEG;IACH,MAAM,EAAE,SAAS,CAAC;IAElB;;OAEG;IACH,gBAAgB,EAAE,oBAAoB,CAAC;IAEvC;;OAEG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAEpB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF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connection {
|
|
|
48
48
|
private _bufferedSignals;
|
|
49
49
|
readonly stateChanged: Event<ConnectionState>;
|
|
50
50
|
readonly errors: ErrorStream;
|
|
51
|
+
_instanceId: string;
|
|
52
|
+
_traceParent?: string;
|
|
53
|
+
_performance: {
|
|
54
|
+
signalsSent: number;
|
|
55
|
+
};
|
|
51
56
|
constructor(topic: PublicKey, ownId: PublicKey, // TODO(burdon): peerID?
|
|
52
57
|
remoteId: PublicKey, sessionId: PublicKey, initiator: boolean, _signalMessaging: SignalMessenger, _protocol: WireProtocol, _transportFactory: TransportFactory);
|
|
53
58
|
get state(): ConnectionState;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../../../src/swarm/connection.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,EAAgB,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../../../src/swarm/connection.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,EAAgB,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAKvC,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD;;GAEG;AACH,oBAAY,eAAe;IACzB;;;OAGG;IACH,OAAO,YAAY;IAEnB;;OAEG;IACH,UAAU,eAAe;IAEzB;;OAEG;IACH,SAAS,cAAc;IAEvB;;OAEG;IACH,OAAO,YAAY;IAEnB;;OAEG;IACH,MAAM,WAAW;CAClB;AAED;;;GAGG;AACH,qBAAa,UAAU;aAeH,KAAK,EAAE,SAAS;aAChB,KAAK,EAAE,SAAS;aAChB,QAAQ,EAAE,SAAS;aACnB,SAAS,EAAE,SAAS;aACpB,SAAS,EAAE,OAAO;IAClC,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IArBpC,OAAO,CAAC,MAAM,CAA4C;IAC1D,OAAO,CAAC,UAAU,CAAwB;IAC1C,OAAO,CAAC,gBAAgB,CAAgB;IAExC,QAAQ,CAAC,YAAY,yBAAgC;IACrD,QAAQ,CAAC,MAAM,cAAqB;IAE7B,WAAW,SAA8B;IACzC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY;;MAEjB;gBAGgB,KAAK,EAAE,SAAS,EAChB,KAAK,EAAE,SAAS,EAAE,wBAAwB;IAC1C,QAAQ,EAAE,SAAS,EACnB,SAAS,EAAE,SAAS,EACpB,SAAS,EAAE,OAAO,EACjB,gBAAgB,EAAE,eAAe,EACjC,SAAS,EAAE,YAAY,EACvB,iBAAiB,EAAE,gBAAgB;IAGtD,IAAI,KAAK,oBAER;IAED,IAAI,SAAS,0BAEZ;IAED,IAAI,QAAQ,iBAEX;IAED;;OAEG;IAEH,cAAc;IAwDR,KAAK;IA8BL,MAAM,CAAC,GAAG,EAAE,aAAa;IAqB/B,OAAO,CAAC,YAAY;CAMrB"}
|
|
@@ -48,6 +48,7 @@ export declare class Peer {
|
|
|
48
48
|
*/
|
|
49
49
|
advertizing: boolean;
|
|
50
50
|
initiating: boolean;
|
|
51
|
+
_traceParent?: string;
|
|
51
52
|
constructor(id: PublicKey, topic: PublicKey, localPeerId: PublicKey, _signalMessaging: SignalMessenger, _protocolProvider: WireProtocolProvider, _transportFactory: TransportFactory, _callbacks: PeerCallbacks);
|
|
52
53
|
/**
|
|
53
54
|
* Respond to remote offer.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"peer.d.ts","sourceRoot":"","sources":["../../../../src/swarm/peer.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAE,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAE/D,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAmB,MAAM,cAAc,CAAC;AAE3D,UAAU,aAAa;IACrB;;OAEG;IACH,WAAW,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;IAE9C;;OAEG;IACH,WAAW,EAAE,MAAM,IAAI,CAAC;IAExB;;OAEG;IACH,cAAc,EAAE,MAAM,IAAI,CAAC;IAE3B;;OAEG;IACH,UAAU,EAAE,MAAM,IAAI,CAAC;IAEvB;;OAEG;IACH,UAAU,EAAE,MAAM,IAAI,CAAC;IAEvB;;OAEG;IACH,OAAO,EAAE,CAAC,QAAQ,EAAE,SAAS,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CACpD;AAED;;;GAGG;AACH,qBAAa,IAAI;
|
|
1
|
+
{"version":3,"file":"peer.d.ts","sourceRoot":"","sources":["../../../../src/swarm/peer.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAE,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAE/D,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAmB,MAA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
27
27
|
/**
|
|
28
28
|
* Unique id of the swarm, local to the current peer, generated when swarm is joined.
|
|
29
29
|
*/
|
|
30
|
-
readonly
|
|
30
|
+
readonly _instanceId: string;
|
|
31
31
|
readonly errors: ErrorStream;
|
|
32
32
|
constructor(_topic: PublicKey, _ownPeerId: PublicKey, _topology: Topology, _protocolProvider: WireProtocolProvider, _messenger: Messenger, _transportFactory: TransportFactory, _label: string | undefined);
|
|
33
33
|
get connections(): Connection[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swarm.d.ts","sourceRoot":"","sources":["../../../../src/swarm/swarm.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"swarm.d.ts","sourceRoot":"","sources":["../../../../src/swarm/swarm.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,UAAU,EAAE,MAAM,wCAAwC,CAAC;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAG/D,OAAO,EAAiB,YAAY,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AACvE,OAAO,EAAmB,QAAQ,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAmB,MAAM,cAAc,CAAC;AAQ3D;;;;GAIG;AACH,qBAAa,KAA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event<void>;
|
|
21
21
|
readonly errors: ErrorStream;
|
|
22
|
+
private readonly _instanceId;
|
|
23
|
+
private readonly _performance;
|
|
22
24
|
constructor(params: WebRTCTransportParams);
|
|
23
25
|
destroy(): Promise<void>;
|
|
24
26
|
signal(signal: Signal): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webrtc-transport.d.ts","sourceRoot":"","sources":["../../../../src/transport/webrtc-transport.ts"],"names":[],"mappings":";AAOA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,WAAW,EAAS,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"webrtc-transport.d.ts","sourceRoot":"","sources":["../../../../src/transport/webrtc-transport.ts"],"names":[],"mappings":";AAOA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,WAAW,EAAS,MAAM,aAAa,CAAC;AAIjD,OAAO,EAAE,MAAM,EAAE,MAAM,uCAAuC,CAAC;AAE/D,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG1D,oBAAY,qBAAqB,GAAG;IAClC,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC,eAAe,CAAC;IAC/B,YAAY,CAAC,EAAE,GAAG,CAAC;IACnB,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/C,CAAC;AAEF;;GAEG;AACH,qBAAa,eAAgB,YAAW,SAAS;IAcnC,OAAO,CAAC,QAAQ,CAAC,MAAM;IAbnC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAa;IACnC,OAAO,CAAC,OAAO,CAAS;IAExB,QAAQ,CAAC,MAAM,cAAe;IAC9B,QAAQ,CAAC,SAAS,cAAe;IACjC,QAAQ,CAAC,MAAM,cAAqB;IAEpC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA8B;IAC1D,OAAO,CAAC,QAAQ,CAAC,YAAY,CAG3B;gBAE2B,MAAM,EAAE,qBAAqB;IA6CpD,OAAO;IAab,MAAM,CAAC,MAAM,EAAE,MAAM;YASP,kBAAkB;CAIjC;AAGD,eAAO,MAAM,4BAA4B,kBAAmB,GAAG,KAAG,gBAMhE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/network-manager",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.34",
|
|
4
4
|
"description": "Network Manager",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -25,20 +25,20 @@
|
|
|
25
25
|
"simple-peer": "9.11.0",
|
|
26
26
|
"ws": "^7.4.4",
|
|
27
27
|
"xor-distance": "^2.0.0",
|
|
28
|
-
"@dxos/async": "0.1.
|
|
29
|
-
"@dxos/codec-protobuf": "0.1.
|
|
30
|
-
"@dxos/context": "0.1.
|
|
31
|
-
"@dxos/credentials": "0.1.
|
|
32
|
-
"@dxos/crypto": "0.1.
|
|
33
|
-
"@dxos/debug": "0.1.
|
|
34
|
-
"@dxos/keys": "0.1.
|
|
35
|
-
"@dxos/log": "0.1.
|
|
36
|
-
"@dxos/messaging": "0.1.
|
|
37
|
-
"@dxos/node-std": "0.1.
|
|
38
|
-
"@dxos/protocols": "0.1.
|
|
39
|
-
"@dxos/rpc": "0.1.
|
|
40
|
-
"@dxos/teleport": "0.1.
|
|
41
|
-
"@dxos/util": "0.1.
|
|
28
|
+
"@dxos/async": "0.1.34",
|
|
29
|
+
"@dxos/codec-protobuf": "0.1.34",
|
|
30
|
+
"@dxos/context": "0.1.34",
|
|
31
|
+
"@dxos/credentials": "0.1.34",
|
|
32
|
+
"@dxos/crypto": "0.1.34",
|
|
33
|
+
"@dxos/debug": "0.1.34",
|
|
34
|
+
"@dxos/keys": "0.1.34",
|
|
35
|
+
"@dxos/log": "0.1.34",
|
|
36
|
+
"@dxos/messaging": "0.1.34",
|
|
37
|
+
"@dxos/node-std": "0.1.34",
|
|
38
|
+
"@dxos/protocols": "0.1.34",
|
|
39
|
+
"@dxos/rpc": "0.1.34",
|
|
40
|
+
"@dxos/teleport": "0.1.34",
|
|
41
|
+
"@dxos/util": "0.1.34"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@swc-node/register": "1.5.4",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"earljs": "~0.1.10",
|
|
49
49
|
"fast-check": "~3.3.0",
|
|
50
50
|
"typescript": "^4.8.4",
|
|
51
|
-
"@dxos/signal": "0.1.
|
|
51
|
+
"@dxos/signal": "0.1.34"
|
|
52
52
|
},
|
|
53
53
|
"publishConfig": {
|
|
54
54
|
"access": "public"
|
package/src/connection-log.ts
CHANGED
|
@@ -36,14 +36,14 @@ export class ConnectionLog {
|
|
|
36
36
|
|
|
37
37
|
joinedSwarm(swarm: Swarm) {
|
|
38
38
|
const info: SwarmInfo = {
|
|
39
|
-
id: swarm.
|
|
39
|
+
id: PublicKey.from(swarm._instanceId),
|
|
40
40
|
topic: swarm.topic,
|
|
41
41
|
isActive: true,
|
|
42
42
|
label: swarm.label,
|
|
43
43
|
connections: []
|
|
44
44
|
};
|
|
45
45
|
|
|
46
|
-
this._swarms.set(swarm.
|
|
46
|
+
this._swarms.set(PublicKey.from(swarm._instanceId), info);
|
|
47
47
|
this.update.emit();
|
|
48
48
|
|
|
49
49
|
swarm.connectionAdded.on((connection) => {
|
|
@@ -96,7 +96,7 @@ export class ConnectionLog {
|
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
leftSwarm(swarm: Swarm) {
|
|
99
|
-
this.getSwarmInfo(swarm.
|
|
99
|
+
this.getSwarmInfo(PublicKey.from(swarm._instanceId)).isActive = false;
|
|
100
100
|
this.update.emit();
|
|
101
101
|
}
|
|
102
102
|
}
|
package/src/network-manager.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { Event } from '@dxos/async';
|
|
|
8
8
|
import { PublicKey } from '@dxos/keys';
|
|
9
9
|
import { log } from '@dxos/log';
|
|
10
10
|
import { Messenger, SignalManager } from '@dxos/messaging';
|
|
11
|
+
import { trace } from '@dxos/protocols';
|
|
11
12
|
import { ConnectionState } from '@dxos/protocols/proto/dxos/client/services';
|
|
12
13
|
import { ComplexMap } from '@dxos/util';
|
|
13
14
|
|
|
@@ -80,6 +81,8 @@ export class NetworkManager {
|
|
|
80
81
|
|
|
81
82
|
public readonly topicsUpdated = new Event<void>();
|
|
82
83
|
|
|
84
|
+
private readonly _instanceId = PublicKey.random().toHex();
|
|
85
|
+
|
|
83
86
|
constructor({ transportFactory, signalManager, log }: NetworkManagerOptions) {
|
|
84
87
|
this._transportFactory = transportFactory;
|
|
85
88
|
|
|
@@ -87,6 +90,7 @@ export class NetworkManager {
|
|
|
87
90
|
this._signalManager = signalManager;
|
|
88
91
|
this._signalManager.swarmEvent.on(({ topic, swarmEvent: event }) => this._swarms.get(topic)?.onSwarmEvent(event));
|
|
89
92
|
this._messenger = new Messenger({ signalManager: this._signalManager });
|
|
93
|
+
this._messenger._traceParent = this._instanceId;
|
|
90
94
|
this._signalConnection = {
|
|
91
95
|
join: (opts) => this._signalManager.join(opts),
|
|
92
96
|
leave: (opts) => this._signalManager.leave(opts)
|
|
@@ -126,6 +130,7 @@ export class NetworkManager {
|
|
|
126
130
|
}
|
|
127
131
|
|
|
128
132
|
async open() {
|
|
133
|
+
log.trace('dxos.mesh.network-manager', trace.begin({ id: this._instanceId }));
|
|
129
134
|
await this._messenger.open();
|
|
130
135
|
await this._signalManager.open();
|
|
131
136
|
}
|
|
@@ -139,6 +144,7 @@ export class NetworkManager {
|
|
|
139
144
|
|
|
140
145
|
await this._messenger.close();
|
|
141
146
|
await this._signalManager.close();
|
|
147
|
+
log.trace('dxos.mesh.network-manager', trace.end({ id: this._instanceId }));
|
|
142
148
|
}
|
|
143
149
|
|
|
144
150
|
/**
|
package/src/swarm/connection.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { Event, synchronized } from '@dxos/async';
|
|
|
8
8
|
import { ErrorStream } from '@dxos/debug';
|
|
9
9
|
import { PublicKey } from '@dxos/keys';
|
|
10
10
|
import { log } from '@dxos/log';
|
|
11
|
+
import { trace } from '@dxos/protocols';
|
|
11
12
|
import { Signal } from '@dxos/protocols/proto/dxos/mesh/swarm';
|
|
12
13
|
|
|
13
14
|
import { SignalMessage, SignalMessenger } from '../signal';
|
|
@@ -57,6 +58,12 @@ export class Connection {
|
|
|
57
58
|
readonly stateChanged = new Event<ConnectionState>();
|
|
58
59
|
readonly errors = new ErrorStream();
|
|
59
60
|
|
|
61
|
+
public _instanceId = PublicKey.random().toHex();
|
|
62
|
+
public _traceParent?: string;
|
|
63
|
+
public _performance = {
|
|
64
|
+
signalsSent: 0
|
|
65
|
+
};
|
|
66
|
+
|
|
60
67
|
constructor(
|
|
61
68
|
public readonly topic: PublicKey,
|
|
62
69
|
public readonly ownId: PublicKey, // TODO(burdon): peerID?
|
|
@@ -87,6 +94,7 @@ export class Connection {
|
|
|
87
94
|
openConnection() {
|
|
88
95
|
assert(this._state === ConnectionState.INITIAL, 'Invalid state.');
|
|
89
96
|
this._changeState(ConnectionState.CONNECTING);
|
|
97
|
+
log.trace('dxos.mesh.connection', trace.begin({ id: this._instanceId, parentId: this._traceParent }));
|
|
90
98
|
|
|
91
99
|
// TODO(dmaretskyi): Initialize only after the transport has established connection.
|
|
92
100
|
this._protocol.initialize().catch((err) => {
|
|
@@ -104,6 +112,7 @@ export class Connection {
|
|
|
104
112
|
initiator: this.initiator,
|
|
105
113
|
stream: this._protocol.stream,
|
|
106
114
|
sendSignal: async (signal) => {
|
|
115
|
+
this._performance.signalsSent++;
|
|
107
116
|
await this._signalMessaging.signal({
|
|
108
117
|
author: this.ownId,
|
|
109
118
|
recipient: this.remoteId,
|
|
@@ -142,7 +151,6 @@ export class Connection {
|
|
|
142
151
|
if (this._state === ConnectionState.CLOSED) {
|
|
143
152
|
return;
|
|
144
153
|
}
|
|
145
|
-
|
|
146
154
|
this._changeState(ConnectionState.CLOSING);
|
|
147
155
|
|
|
148
156
|
log('closing...', { peerId: this.ownId });
|
|
@@ -163,6 +171,10 @@ export class Connection {
|
|
|
163
171
|
|
|
164
172
|
log('closed', { peerId: this.ownId });
|
|
165
173
|
this._changeState(ConnectionState.CLOSED);
|
|
174
|
+
log.trace(
|
|
175
|
+
'dxos.mesh.connection',
|
|
176
|
+
trace.end({ id: this._instanceId, status: 'ok', data: { performance: this._performance } })
|
|
177
|
+
);
|
|
166
178
|
}
|
|
167
179
|
|
|
168
180
|
async signal(msg: SignalMessage) {
|
package/src/swarm/peer.ts
CHANGED
|
@@ -60,6 +60,8 @@ export class Peer {
|
|
|
60
60
|
|
|
61
61
|
public initiating = false;
|
|
62
62
|
|
|
63
|
+
public _traceParent?: string;
|
|
64
|
+
|
|
63
65
|
constructor(
|
|
64
66
|
public readonly id: PublicKey,
|
|
65
67
|
public readonly topic: PublicKey,
|
|
@@ -182,6 +184,7 @@ export class Peer {
|
|
|
182
184
|
this._protocolProvider({ initiator, localPeerId: this.localPeerId, remotePeerId: this.id, topic: this.topic }),
|
|
183
185
|
this._transportFactory
|
|
184
186
|
);
|
|
187
|
+
connection._traceParent = this._traceParent;
|
|
185
188
|
this._callbacks.onInitiated(connection);
|
|
186
189
|
connection.stateChanged.on((state) => {
|
|
187
190
|
switch (state) {
|
package/src/swarm/swarm.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { ErrorStream } from '@dxos/debug';
|
|
|
10
10
|
import { PublicKey } from '@dxos/keys';
|
|
11
11
|
import { log, logInfo } from '@dxos/log';
|
|
12
12
|
import { Messenger } from '@dxos/messaging';
|
|
13
|
+
import { trace } from '@dxos/protocols';
|
|
13
14
|
import { SwarmEvent } from '@dxos/protocols/proto/dxos/mesh/signal';
|
|
14
15
|
import { Answer } from '@dxos/protocols/proto/dxos/mesh/swarm';
|
|
15
16
|
import { ComplexMap, isNotNullOrUndefined } from '@dxos/util';
|
|
@@ -46,7 +47,7 @@ export class Swarm {
|
|
|
46
47
|
* Unique id of the swarm, local to the current peer, generated when swarm is joined.
|
|
47
48
|
*/
|
|
48
49
|
@logInfo
|
|
49
|
-
readonly
|
|
50
|
+
readonly _instanceId = PublicKey.random().toHex();
|
|
50
51
|
|
|
51
52
|
/**
|
|
52
53
|
* New connection to a peer is started.
|
|
@@ -97,6 +98,11 @@ export class Swarm {
|
|
|
97
98
|
onMessage: async (message) => await this._swarmMessenger.receiveMessage(message)
|
|
98
99
|
})
|
|
99
100
|
.catch((error) => log.catch(error));
|
|
101
|
+
|
|
102
|
+
log.trace(
|
|
103
|
+
'dxos.mesh.swarm',
|
|
104
|
+
trace.begin({ id: this._instanceId, data: { topic: this._topic.toHex(), peerId: this._ownPeerId.toHex() } })
|
|
105
|
+
);
|
|
100
106
|
}
|
|
101
107
|
|
|
102
108
|
get connections() {
|
|
@@ -129,6 +135,7 @@ export class Swarm {
|
|
|
129
135
|
await this._topology.destroy();
|
|
130
136
|
await Promise.all(Array.from(this._peers.keys()).map((key) => this._destroyPeer(key)));
|
|
131
137
|
log('destroyed');
|
|
138
|
+
log.trace('dxos.mesh.swarm', trace.end({ id: this._instanceId }));
|
|
132
139
|
}
|
|
133
140
|
|
|
134
141
|
async setTopology(topology: Topology) {
|
|
@@ -273,6 +280,7 @@ export class Swarm {
|
|
|
273
280
|
}
|
|
274
281
|
}
|
|
275
282
|
);
|
|
283
|
+
peer._traceParent = this._instanceId;
|
|
276
284
|
this._peers.set(peerId, peer);
|
|
277
285
|
}
|
|
278
286
|
|
|
@@ -7,7 +7,9 @@ import SimplePeerConstructor, { Instance as SimplePeer } from 'simple-peer';
|
|
|
7
7
|
|
|
8
8
|
import { Event } from '@dxos/async';
|
|
9
9
|
import { ErrorStream, raise } from '@dxos/debug';
|
|
10
|
+
import { PublicKey } from '@dxos/keys';
|
|
10
11
|
import { log } from '@dxos/log';
|
|
12
|
+
import { trace } from '@dxos/protocols';
|
|
11
13
|
import { Signal } from '@dxos/protocols/proto/dxos/mesh/swarm';
|
|
12
14
|
|
|
13
15
|
import { Transport, TransportFactory } from './transport';
|
|
@@ -31,7 +33,14 @@ export class WebRTCTransport implements Transport {
|
|
|
31
33
|
readonly connected = new Event();
|
|
32
34
|
readonly errors = new ErrorStream();
|
|
33
35
|
|
|
36
|
+
private readonly _instanceId = PublicKey.random().toHex();
|
|
37
|
+
private readonly _performance = {
|
|
38
|
+
bytesSent: 0,
|
|
39
|
+
bytesReceived: 0
|
|
40
|
+
};
|
|
41
|
+
|
|
34
42
|
constructor(private readonly params: WebRTCTransportParams) {
|
|
43
|
+
log.trace('dxos.mesh.webrtc-transport', trace.begin({ id: this._instanceId }));
|
|
35
44
|
log('created connection', params);
|
|
36
45
|
this._peer = new SimplePeerConstructor({
|
|
37
46
|
initiator: this.params.initiator,
|
|
@@ -82,6 +91,10 @@ export class WebRTCTransport implements Transport {
|
|
|
82
91
|
this._peer!.destroy();
|
|
83
92
|
this.closed.emit();
|
|
84
93
|
log('closed');
|
|
94
|
+
log.trace(
|
|
95
|
+
'dxos.mesh.webrtc-transport',
|
|
96
|
+
trace.end({ id: this._instanceId, data: { performance: this._performance } })
|
|
97
|
+
);
|
|
85
98
|
}
|
|
86
99
|
|
|
87
100
|
signal(signal: Signal) {
|