@streamr/trackerless-network 100.0.0-testnet-one.3 → 100.0.0-testnet-two.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 (125) hide show
  1. package/dist/package.json +7 -7
  2. package/dist/src/NetworkStack.d.ts +1 -5
  3. package/dist/src/NetworkStack.js +1 -3
  4. package/dist/src/NetworkStack.js.map +1 -1
  5. package/dist/src/logic/DeliveryRpcLocal.d.ts +1 -1
  6. package/dist/src/logic/DeliveryRpcLocal.js +3 -3
  7. package/dist/src/logic/DeliveryRpcLocal.js.map +1 -1
  8. package/dist/src/logic/DeliveryRpcRemote.d.ts +3 -3
  9. package/dist/src/logic/DeliveryRpcRemote.js +3 -2
  10. package/dist/src/logic/DeliveryRpcRemote.js.map +1 -1
  11. package/dist/src/logic/EntryPointDiscovery.d.ts +3 -0
  12. package/dist/src/logic/EntryPointDiscovery.js +11 -5
  13. package/dist/src/logic/EntryPointDiscovery.js.map +1 -1
  14. package/dist/src/logic/RandomGraphNode.d.ts +10 -8
  15. package/dist/src/logic/RandomGraphNode.js +23 -17
  16. package/dist/src/logic/RandomGraphNode.js.map +1 -1
  17. package/dist/src/logic/StreamrNode.js +13 -4
  18. package/dist/src/logic/StreamrNode.js.map +1 -1
  19. package/dist/src/logic/formStreamPartDeliveryServiceId.d.ts +2 -1
  20. package/dist/src/logic/formStreamPartDeliveryServiceId.js.map +1 -1
  21. package/dist/src/logic/inspect/Inspector.d.ts +5 -11
  22. package/dist/src/logic/inspect/Inspector.js +2 -3
  23. package/dist/src/logic/inspect/Inspector.js.map +1 -1
  24. package/dist/src/logic/neighbor-discovery/HandshakeRpcLocal.d.ts +3 -3
  25. package/dist/src/logic/neighbor-discovery/HandshakeRpcLocal.js +39 -13
  26. package/dist/src/logic/neighbor-discovery/HandshakeRpcLocal.js.map +1 -1
  27. package/dist/src/logic/neighbor-discovery/HandshakeRpcRemote.d.ts +5 -3
  28. package/dist/src/logic/neighbor-discovery/HandshakeRpcRemote.js +18 -8
  29. package/dist/src/logic/neighbor-discovery/HandshakeRpcRemote.js.map +1 -1
  30. package/dist/src/logic/neighbor-discovery/Handshaker.d.ts +1 -6
  31. package/dist/src/logic/neighbor-discovery/Handshaker.js +6 -6
  32. package/dist/src/logic/neighbor-discovery/Handshaker.js.map +1 -1
  33. package/dist/src/logic/neighbor-discovery/NeighborFinder.d.ts +1 -6
  34. package/dist/src/logic/neighbor-discovery/NeighborFinder.js.map +1 -1
  35. package/dist/src/logic/neighbor-discovery/NeighborUpdateManager.d.ts +3 -8
  36. package/dist/src/logic/neighbor-discovery/NeighborUpdateManager.js +1 -3
  37. package/dist/src/logic/neighbor-discovery/NeighborUpdateManager.js.map +1 -1
  38. package/dist/src/logic/neighbor-discovery/NeighborUpdateRpcLocal.d.ts +2 -2
  39. package/dist/src/logic/neighbor-discovery/NeighborUpdateRpcLocal.js +1 -2
  40. package/dist/src/logic/neighbor-discovery/NeighborUpdateRpcLocal.js.map +1 -1
  41. package/dist/src/logic/neighbor-discovery/NeighborUpdateRpcRemote.d.ts +2 -2
  42. package/dist/src/logic/neighbor-discovery/NeighborUpdateRpcRemote.js.map +1 -1
  43. package/dist/src/logic/proxy/ProxyClient.d.ts +4 -1
  44. package/dist/src/logic/proxy/ProxyClient.js +7 -6
  45. package/dist/src/logic/proxy/ProxyClient.js.map +1 -1
  46. package/dist/src/logic/proxy/ProxyConnectionRpcLocal.js +2 -3
  47. package/dist/src/logic/proxy/ProxyConnectionRpcLocal.js.map +1 -1
  48. package/dist/src/logic/proxy/ProxyConnectionRpcRemote.d.ts +2 -2
  49. package/dist/src/logic/proxy/ProxyConnectionRpcRemote.js.map +1 -1
  50. package/dist/src/logic/temporary-connection/TemporaryConnectionRpcLocal.js +2 -2
  51. package/dist/src/logic/temporary-connection/TemporaryConnectionRpcLocal.js.map +1 -1
  52. package/dist/src/logic/temporary-connection/TemporaryConnectionRpcRemote.d.ts +2 -2
  53. package/dist/src/logic/temporary-connection/TemporaryConnectionRpcRemote.js.map +1 -1
  54. package/dist/src/proto/packages/dht/protos/DhtRpc.client.d.ts +21 -22
  55. package/dist/src/proto/packages/dht/protos/DhtRpc.client.js +18 -18
  56. package/dist/src/proto/packages/dht/protos/DhtRpc.client.js.map +1 -1
  57. package/dist/src/proto/packages/dht/protos/DhtRpc.d.ts +36 -60
  58. package/dist/src/proto/packages/dht/protos/DhtRpc.js +34 -53
  59. package/dist/src/proto/packages/dht/protos/DhtRpc.js.map +1 -1
  60. package/dist/src/proto/packages/dht/protos/DhtRpc.server.d.ts +11 -12
  61. package/dist/src/proto/packages/trackerless-network/protos/NetworkRpc.client.d.ts +6 -5
  62. package/dist/src/proto/packages/trackerless-network/protos/NetworkRpc.client.js +2 -2
  63. package/dist/src/proto/packages/trackerless-network/protos/NetworkRpc.client.js.map +1 -1
  64. package/dist/src/proto/packages/trackerless-network/protos/NetworkRpc.d.ts +26 -10
  65. package/dist/src/proto/packages/trackerless-network/protos/NetworkRpc.js +21 -9
  66. package/dist/src/proto/packages/trackerless-network/protos/NetworkRpc.js.map +1 -1
  67. package/dist/src/proto/packages/trackerless-network/protos/NetworkRpc.server.d.ts +4 -3
  68. package/dist/test/benchmark/first-message.js +4 -6
  69. package/dist/test/benchmark/first-message.js.map +1 -1
  70. package/dist/test/utils/utils.d.ts +1 -1
  71. package/dist/test/utils/utils.js +8 -7
  72. package/dist/test/utils/utils.js.map +1 -1
  73. package/package.json +7 -7
  74. package/protos/NetworkRpc.proto +8 -4
  75. package/src/NetworkStack.ts +1 -7
  76. package/src/logic/DeliveryRpcLocal.ts +4 -4
  77. package/src/logic/DeliveryRpcRemote.ts +5 -4
  78. package/src/logic/EntryPointDiscovery.ts +10 -6
  79. package/src/logic/RandomGraphNode.ts +38 -25
  80. package/src/logic/StreamrNode.ts +22 -5
  81. package/src/logic/formStreamPartDeliveryServiceId.ts +2 -1
  82. package/src/logic/inspect/Inspector.ts +15 -16
  83. package/src/logic/neighbor-discovery/HandshakeRpcLocal.ts +46 -15
  84. package/src/logic/neighbor-discovery/HandshakeRpcRemote.ts +21 -10
  85. package/src/logic/neighbor-discovery/Handshaker.ts +15 -24
  86. package/src/logic/neighbor-discovery/NeighborFinder.ts +1 -7
  87. package/src/logic/neighbor-discovery/NeighborUpdateManager.ts +10 -12
  88. package/src/logic/neighbor-discovery/NeighborUpdateRpcLocal.ts +4 -4
  89. package/src/logic/neighbor-discovery/NeighborUpdateRpcRemote.ts +2 -2
  90. package/src/logic/proxy/ProxyClient.ts +19 -7
  91. package/src/logic/proxy/ProxyConnectionRpcLocal.ts +3 -3
  92. package/src/logic/proxy/ProxyConnectionRpcRemote.ts +3 -3
  93. package/src/logic/temporary-connection/TemporaryConnectionRpcLocal.ts +3 -2
  94. package/src/logic/temporary-connection/TemporaryConnectionRpcRemote.ts +2 -2
  95. package/src/proto/packages/dht/protos/DhtRpc.client.ts +31 -32
  96. package/src/proto/packages/dht/protos/DhtRpc.server.ts +11 -12
  97. package/src/proto/packages/dht/protos/DhtRpc.ts +49 -80
  98. package/src/proto/packages/trackerless-network/protos/NetworkRpc.client.ts +7 -6
  99. package/src/proto/packages/trackerless-network/protos/NetworkRpc.server.ts +4 -3
  100. package/src/proto/packages/trackerless-network/protos/NetworkRpc.ts +36 -15
  101. package/test/benchmark/first-message.ts +8 -6
  102. package/test/end-to-end/random-graph-with-real-connections.test.ts +10 -5
  103. package/test/end-to-end/webrtc-full-node-network.test.ts +1 -1
  104. package/test/end-to-end/websocket-full-node-network.test.ts +2 -2
  105. package/test/integration/DeliveryRpcRemote.test.ts +3 -3
  106. package/test/integration/HandshakeRpcRemote.test.ts +2 -4
  107. package/test/integration/Handshakes.test.ts +8 -7
  108. package/test/integration/Inspect.test.ts +0 -2
  109. package/test/integration/NeighborUpdateRpcRemote.test.ts +2 -2
  110. package/test/integration/NetworkNode.test.ts +0 -2
  111. package/test/integration/NetworkRpc.test.ts +0 -3
  112. package/test/integration/RandomGraphNode-Layer1Node-Latencies.test.ts +4 -4
  113. package/test/integration/RandomGraphNode-Layer1Node.test.ts +4 -5
  114. package/test/integration/stream-without-default-entrypoints.test.ts +4 -7
  115. package/test/integration/streamEntryPointReplacing.test.ts +94 -0
  116. package/test/unit/DeliveryRpcLocal.test.ts +2 -1
  117. package/test/unit/EntrypointDiscovery.test.ts +5 -2
  118. package/test/unit/HandshakeRpcLocal.test.ts +47 -9
  119. package/test/unit/NodeList.test.ts +10 -12
  120. package/test/unit/ProxyConnectionRpcRemote.test.ts +18 -10
  121. package/test/unit/RandomGraphNode.test.ts +6 -4
  122. package/test/utils/mock/MockHandshaker.ts +3 -2
  123. package/test/utils/mock/MockNeighborFinder.ts +3 -2
  124. package/test/utils/mock/MockNeighborUpdateManager.ts +3 -2
  125. package/test/utils/utils.ts +16 -8
@@ -1,7 +1,8 @@
1
1
  import { TemporaryConnectionResponse } from "./NetworkRpc";
2
2
  import { TemporaryConnectionRequest } from "./NetworkRpc";
3
3
  import { NeighborUpdate } from "./NetworkRpc";
4
- import { InterleaveNotice } from "./NetworkRpc";
4
+ import { InterleaveResponse } from "./NetworkRpc";
5
+ import { InterleaveRequest } from "./NetworkRpc";
5
6
  import { StreamPartHandshakeResponse } from "./NetworkRpc";
6
7
  import { StreamPartHandshakeRequest } from "./NetworkRpc";
7
8
  import { ProxyConnectionResponse } from "./NetworkRpc";
@@ -41,9 +42,9 @@ export interface IHandshakeRpc<T = ServerCallContext> {
41
42
  */
42
43
  handshake(request: StreamPartHandshakeRequest, context: T): Promise<StreamPartHandshakeResponse>;
43
44
  /**
44
- * @generated from protobuf rpc: interleaveNotice(InterleaveNotice) returns (google.protobuf.Empty);
45
+ * @generated from protobuf rpc: interleaveRequest(InterleaveRequest) returns (InterleaveResponse);
45
46
  */
46
- interleaveNotice(request: InterleaveNotice, context: T): Promise<Empty>;
47
+ interleaveRequest(request: InterleaveRequest, context: T): Promise<InterleaveResponse>;
47
48
  }
48
49
  /**
49
50
  * @generated from protobuf service NeighborUpdateRpc
@@ -28,7 +28,7 @@ const prepareLayer0 = async () => {
28
28
  region: (0, dht_1.getRandomRegion)()
29
29
  });
30
30
  layer0Ep = peerDescriptor;
31
- const entryPoint = (0, utils_2.createNetworkNodeWithSimulator)(peerDescriptor, simulator, [peerDescriptor]);
31
+ const entryPoint = await (0, utils_2.createNetworkNodeWithSimulator)(peerDescriptor, simulator, [peerDescriptor]);
32
32
  await entryPoint.start();
33
33
  nodes.push(entryPoint);
34
34
  console.log('Entrypoint ready');
@@ -39,7 +39,7 @@ const prepareStream = async (streamId) => {
39
39
  region: (0, dht_1.getRandomRegion)()
40
40
  });
41
41
  const streamPartId = (0, protocol_1.toStreamPartID)((0, protocol_1.toStreamID)(streamId), 0);
42
- const streamPublisher = (0, utils_2.createNetworkNodeWithSimulator)(peerDescriptor, simulator, [layer0Ep]);
42
+ const streamPublisher = await (0, utils_2.createNetworkNodeWithSimulator)(peerDescriptor, simulator, [layer0Ep]);
43
43
  await streamPublisher.start();
44
44
  streamPublisher.join(streamPartId);
45
45
  nodes.push(streamPublisher);
@@ -63,7 +63,7 @@ const measureJoiningTime = async () => {
63
63
  publishInterval = setInterval(() => {
64
64
  i += 1;
65
65
  const streamMessage = new protocol_1.StreamMessage({
66
- messageId: new protocol_1.MessageID(protocol_1.StreamPartIDUtils.getStreamID(stream), 0, i, Math.floor(Math.random() * 20000), 'node', 'msgChainId'),
66
+ messageId: new protocol_1.MessageID(protocol_1.StreamPartIDUtils.getStreamID(stream), 0, i, Math.floor(Math.random() * 20000), '2222', 'msgChainId'),
67
67
  prevMsgRef: null,
68
68
  content: (0, utils_1.utf8ToBinary)(JSON.stringify({
69
69
  hello: 'world'
@@ -75,7 +75,7 @@ const measureJoiningTime = async () => {
75
75
  }, 1000);
76
76
  // get random node from network to use as entrypoint
77
77
  const randomNode = nodes[Math.floor(Math.random() * nodes.length)];
78
- const streamSubscriber = (0, utils_2.createNetworkNodeWithSimulator)(peerDescriptor, simulator, [randomNode.stack.getLayer0Node().getLocalPeerDescriptor()]);
78
+ const streamSubscriber = await (0, utils_2.createNetworkNodeWithSimulator)(peerDescriptor, simulator, [randomNode.stack.getLayer0Node().getLocalPeerDescriptor()]);
79
79
  currentNode = streamSubscriber;
80
80
  const start = performance.now();
81
81
  await streamSubscriber.start();
@@ -90,7 +90,6 @@ const measureJoiningTime = async () => {
90
90
  return end - start;
91
91
  };
92
92
  const run = async () => {
93
- dht_1.Simulator.useFakeTimers();
94
93
  await prepareLayer0();
95
94
  for (let i = 0; i < 20; i++) {
96
95
  await prepareStream(`stream-${i}`);
@@ -104,7 +103,6 @@ const run = async () => {
104
103
  }
105
104
  fs_1.default.closeSync(logFile);
106
105
  await shutdownNetwork();
107
- dht_1.Simulator.useFakeTimers(false);
108
106
  };
109
107
  // eslint-disable-next-line promise/catch-or-return, promise/always-return
110
108
  run().then(() => {
@@ -1 +1 @@
1
- {"version":3,"file":"first-message.js","sourceRoot":"","sources":["../../../test/benchmark/first-message.ts"],"names":[],"mappings":";AAAA,+BAA+B;;;;;AAE/B,sCAA+E;AAC/E,gDAA4I;AAC5I,0CAAyE;AACzE,4CAAmB;AAGnB,uDAAmE;AACnE,6EAA2E;AAC3E,0CAAyF;AAIzF,MAAM,QAAQ,GAAG,KAAK,CAAA;AAEtB,IAAI,KAAoB,CAAA;AACxB,IAAI,SAAoB,CAAA;AACxB,IAAI,QAAwB,CAAA;AAC5B,MAAM,gBAAgB,GAAqB,EAAE,CAAA;AAC7C,MAAM,WAAW,GAAmC,IAAI,GAAG,EAAE,CAAA;AAC7D,IAAI,WAAwB,CAAA;AAC5B,IAAI,eAA2C,CAAA;AAC/C,IAAI,CAAC,GAAG,CAAC,CAAA;AAET,MAAM,aAAa,GAAG,KAAK,IAAI,EAAE;IAC7B,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAA;IAChC,KAAK,GAAG,EAAE,CAAA;IACV,SAAS,GAAG,IAAI,eAAS,CAAC,iBAAW,CAAC,IAAI,CAAC,CAAA;IAC3C,MAAM,cAAc,GAAG,I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AC,CAAA;IAC9D,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,sBAAsB,EAAE,CAAC,CAAA;IAChD,MAAM,kBAAkB,GAAG,WAAW,CAAC,qBAAqB,CAAC,WAAW,CAAC,CAAC,CAAC,CAAuD,CAAA;IAClI,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,UAAU,CAAC,6BAA6B,EAAE,CAAC,CAAA;IAC1E,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,IAAI,CAAC,oBAAoB,EAAE,CAAC,CAAA;IAC3D,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAA;IACpC,IAAI,eAAe,EAAE;QACjB,aAAa,CAAC,eAAe,CAAC,CAAA;KACjC;AACL,CAAC,CAAC,CAAA"}
@@ -15,4 +15,4 @@ export declare const createRandomNodeId: () => NodeID;
15
15
  export declare const createMockPeerDescriptor: (opts?: Omit<Partial<PeerDescriptor>, 'nodeId' | 'type'>) => PeerDescriptor;
16
16
  export declare const createMockDeliveryRpcRemote: (remotePeerDescriptor?: PeerDescriptor) => DeliveryRpcRemote;
17
17
  export declare const createMockHandshakeRpcRemote: () => HandshakeRpcRemote;
18
- export declare const createNetworkNodeWithSimulator: (peerDescriptor: PeerDescriptor, simulator: Simulator, entryPoints: PeerDescriptor[]) => NetworkNode;
18
+ export declare const createNetworkNodeWithSimulator: (peerDescriptor: PeerDescriptor, simulator: Simulator, entryPoints: PeerDescriptor[]) => Promise<NetworkNode>;
@@ -10,6 +10,8 @@ const HandshakeRpcRemote_1 = require("../../src/logic/neighbor-discovery/Handsha
10
10
  const NetworkNode_1 = require("../../src/NetworkNode");
11
11
  const utils_1 = require("@streamr/utils");
12
12
  const protocol_1 = require("@streamr/protocol");
13
+ const NetworkRpc_client_1 = require("../../src/proto/packages/trackerless-network/protos/NetworkRpc.client");
14
+ const proto_rpc_1 = require("@streamr/proto-rpc");
13
15
  exports.mockConnectionLocker = {
14
16
  lockConnection: () => { },
15
17
  unlockConnection: () => { },
@@ -32,7 +34,8 @@ const createMockRandomGraphNodeAndDhtNode = async (localPeerDescriptor, entryPoi
32
34
  layer1Node,
33
35
  connectionLocker: mockCm,
34
36
  localPeerDescriptor,
35
- rpcRequestTimeout: 5000
37
+ rpcRequestTimeout: 5000,
38
+ isLocalNodeEntryPoint: () => false
36
39
  });
37
40
  return [layer1Node, randomGraphNode];
38
41
  };
@@ -71,18 +74,16 @@ const createMockPeerDescriptor = (opts) => {
71
74
  };
72
75
  exports.createMockPeerDescriptor = createMockPeerDescriptor;
73
76
  const createMockDeliveryRpcRemote = (remotePeerDescriptor) => {
74
- return new DeliveryRpcRemote_1.DeliveryRpcRemote((0, exports.createMockPeerDescriptor)(), remotePeerDescriptor ?? (0, exports.createMockPeerDescriptor)(), 'mock', {});
77
+ return new DeliveryRpcRemote_1.DeliveryRpcRemote((0, exports.createMockPeerDescriptor)(), remotePeerDescriptor ?? (0, exports.createMockPeerDescriptor)(), 'mock', new proto_rpc_1.RpcCommunicator(), NetworkRpc_client_1.DeliveryRpcClient);
75
78
  };
76
79
  exports.createMockDeliveryRpcRemote = createMockDeliveryRpcRemote;
77
80
  const createMockHandshakeRpcRemote = () => {
78
- return new HandshakeRpcRemote_1.HandshakeRpcRemote((0, exports.createMockPeerDescriptor)(), (0, exports.createMockPeerDescriptor)(), 'mock', {
79
- handshake: async () => { },
80
- interleaveNotice: async () => { }
81
- });
81
+ return new HandshakeRpcRemote_1.HandshakeRpcRemote((0, exports.createMockPeerDescriptor)(), (0, exports.createMockPeerDescriptor)(), 'mock', new proto_rpc_1.RpcCommunicator(), NetworkRpc_client_1.HandshakeRpcClient);
82
82
  };
83
83
  exports.createMockHandshakeRpcRemote = createMockHandshakeRpcRemote;
84
- const createNetworkNodeWithSimulator = (peerDescriptor, simulator, entryPoints) => {
84
+ const createNetworkNodeWithSimulator = async (peerDescriptor, simulator, entryPoints) => {
85
85
  const transport = new dht_1.SimulatorTransport(peerDescriptor, simulator);
86
+ await transport.start();
86
87
  return (0, NetworkNode_1.createNetworkNode)({
87
88
  layer0: {
88
89
  peerDescriptor,
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../test/utils/utils.ts"],"names":[],"mappings":";;;AAAA,mCAAoC;AACpC,sCAAkI;AAElI,+FAMuE;AACvE,yEAAqE;AACrE,iFAA6E;AAC7E,8FAA0F;AAC1F,uDAAsE;AACtE,0CAA2E;AAC3E,gDAAmE;AAItD,QAAA,oBAAoB,GAAqB;IAClD,cAAc,EAAE,GAAG,EAAE,GAAE,CAAC;IACxB,gBAAgB,EAAE,GAAG,EAAE,GAAE,CAAC;IAC1B,kBAAkB,EAAE,GAAG,EAAE,GAAE,CAAC;IAC5B,oBAAoB,EAAE,GAAG,EAAE,GAAE,CAAC;CACjC,CAAA;AAEM,MAAM,mCAAmC,GAAG,KAAK,EACpD,mBAAmC,EACnC,oBAAoC,EACpC,YAA0B,EAC1B,SAAoB,EACoB,EAAE;IAC1C,MAAM,MAAM,GAAG,IAAI,wBAAkB,CAAC,mBAAmB,EAAE,SAAS,CAAC,CAAA;IACrE,MAAM,MAAM,CAAC,KAAK,EAAE,CAAA;IACpB,MAAM,UAAU,GAAG,IAAI,aAAO,CAAC;QAC3B,SAAS,EAAE,MAAM;QACjB,cAAc,EAAE,mBAAmB;QACnC,uBAAuB,EAAE,CAAC;QAC1B,WAAW,EAAE,CAAC,oBAAoB,CAAC;QACnC,iBAAiB,EAAE,IAAI;KAC1B,CAAC,CAAA;IACF,MAAM,eAAe,GAAG,IAAA,6CAAqB,EAAC;QAC1C,YAAY;QACZ,SAAS,EAAE,MAAM;QACjB,UAAU;QACV,gBAAgB,EAAE,MAAM;QACxB,mBAAmB;QACnB,iBAAiB,EAAE,IAAI;KAC1B,CAAC,CAAA;IACF,OAAO,CAAC,UAAU,EAAE,eAAe,CAAC,CAAA;AACxC,CAAC,CAAA;AAxBY,QAAA,mCAAmC,uCAwB/C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ACrB,sCAAkB,CACrB,CAAA;AACL,CAAC,CAAA;AARY,QAAA,4BAA4B,gCAQxC;AAEM,MAAM,8BAA8B,GAAG,KAAK,EAC/C,cAA8B,EAC9B,SAAoB,EACpB,WAA6B,EACT,EAAE;IACtB,MAAM,SAAS,GAAG,IAAI,wBAAkB,CAAC,cAAc,EAAE,SAAS,CAAC,CAAA;IACnE,MAAM,SAAS,CAAC,KAAK,EAAE,CAAA;IACvB,OAAO,IAAA,+BAAiB,EAAC;QACrB,MAAM,EAAE;YACJ,cAAc;YACd,WAAW;YACX,SAAS;YACT,cAAc,EAAE,EAAE;YAClB,eAAe,EAAE,MAAM;YACvB,WAAW,EAAE,MAAM;SACtB;KACJ,CAAC,CAAA;AACN,CAAC,CAAA;AAjBY,QAAA,8BAA8B,kCAiB1C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamr/trackerless-network",
3
- "version": "100.0.0-testnet-one.3",
3
+ "version": "100.0.0-testnet-two.0",
4
4
  "description": "Minimal and extendable implementation of the Streamr Network node.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -30,11 +30,11 @@
30
30
  "dependencies": {
31
31
  "@protobuf-ts/runtime": "^2.8.2",
32
32
  "@protobuf-ts/runtime-rpc": "^2.8.2",
33
- "@streamr/dht": "100.0.0-testnet-one.3",
34
- "@streamr/proto-rpc": "100.0.0-testnet-one.3",
35
- "@streamr/protocol": "100.0.0-testnet-one.3",
36
- "@streamr/test-utils": "100.0.0-testnet-one.3",
37
- "@streamr/utils": "100.0.0-testnet-one.3",
33
+ "@streamr/dht": "100.0.0-testnet-two.0",
34
+ "@streamr/proto-rpc": "100.0.0-testnet-two.0",
35
+ "@streamr/protocol": "100.0.0-testnet-two.0",
36
+ "@streamr/test-utils": "100.0.0-testnet-two.0",
37
+ "@streamr/utils": "100.0.0-testnet-two.0",
38
38
  "eventemitter3": "^5.0.0",
39
39
  "lodash": "^4.17.21",
40
40
  "uuid": "^9.0.1",
@@ -42,7 +42,7 @@
42
42
  },
43
43
  "devDependencies": {
44
44
  "@streamr/browser-test-runner": "^0.0.1",
45
- "@types/lodash": "^4.14.201",
45
+ "@types/lodash": "^4.14.202",
46
46
  "@types/uuid": "^9.0.7",
47
47
  "@types/yallist": "^4.0.1",
48
48
  "commander": "^11.1.0",
@@ -17,7 +17,7 @@ service ProxyConnectionRpc {
17
17
 
18
18
  service HandshakeRpc {
19
19
  rpc handshake (StreamPartHandshakeRequest) returns (StreamPartHandshakeResponse);
20
- rpc interleaveNotice (InterleaveNotice) returns (google.protobuf.Empty);
20
+ rpc interleaveRequest (InterleaveRequest) returns (InterleaveResponse);
21
21
  }
22
22
 
23
23
  service NeighborUpdateRpc {
@@ -103,14 +103,18 @@ message StreamPartHandshakeResponse {
103
103
  optional dht.PeerDescriptor interleaveTargetDescriptor = 3;
104
104
  }
105
105
 
106
- message InterleaveNotice {
107
- string streamPartId = 1;
106
+ message InterleaveRequest {
108
107
  // this is a required field but in generated NetworkRpc.ts it is incorrectly annotated as optional (NET-1082)
109
- dht.PeerDescriptor interleaveTargetDescriptor = 2;
108
+ dht.PeerDescriptor interleaveTargetDescriptor = 1;
109
+ }
110
+
111
+ message InterleaveResponse {
112
+ bool accepted = 1;
110
113
  }
111
114
 
112
115
  message LeaveStreamPartNotice {
113
116
  string streamPartId = 1;
117
+ bool isEntryPoint = 2;
114
118
  }
115
119
 
116
120
  message NeighborUpdate {
@@ -1,7 +1,6 @@
1
1
  import { ConnectionManager, DhtNode, DhtNodeOptions, areEqualPeerDescriptors } from '@streamr/dht'
2
2
  import { StreamrNode, StreamrNodeConfig } from './logic/StreamrNode'
3
3
  import { MetricsContext, waitForCondition } from '@streamr/utils'
4
- import { EventEmitter } from 'eventemitter3'
5
4
  import { StreamID, StreamPartID, toStreamPartID } from '@streamr/protocol'
6
5
  import { ProxyDirection, StreamMessage, StreamMessageType } from './proto/packages/trackerless-network/protos/NetworkRpc'
7
6
  import { Layer0Node } from './logic/Layer0Node'
@@ -13,10 +12,6 @@ export interface NetworkOptions {
13
12
  metricsContext?: MetricsContext
14
13
  }
15
14
 
16
- export interface NetworkStackEvents {
17
- stopped: () => void
18
- }
19
-
20
15
  const instances: NetworkStack[] = []
21
16
  const stopInstances = async () => {
22
17
  // make a clone so that it is ok for each instance.stop() to remove itself from the list (at line 139)
@@ -38,7 +33,7 @@ if (typeof window === 'object') {
38
33
  })
39
34
  }
40
35
 
41
- export class NetworkStack extends EventEmitter<NetworkStackEvents> {
36
+ export class NetworkStack {
42
37
 
43
38
  private layer0Node?: Layer0Node
44
39
  private streamrNode?: StreamrNode
@@ -47,7 +42,6 @@ export class NetworkStack extends EventEmitter<NetworkStackEvents> {
47
42
  private readonly options: NetworkOptions
48
43
 
49
44
  constructor(options: NetworkOptions) {
50
- super()
51
45
  this.options = options
52
46
  this.metricsContext = options.metricsContext ?? new MetricsContext()
53
47
  this.layer0Node = new DhtNode({
@@ -16,7 +16,7 @@ export interface DeliveryRpcLocalConfig {
16
16
  streamPartId: StreamPartID
17
17
  markAndCheckDuplicate: (messageId: MessageID, previousMessageRef?: MessageRef) => boolean
18
18
  broadcast: (message: StreamMessage, previousNode?: NodeID) => void
19
- onLeaveNotice(senderId: NodeID): void
19
+ onLeaveNotice(senderId: NodeID, isLocalNodeEntryPoint: boolean): void
20
20
  markForInspection(senderId: NodeID, messageId: MessageID): void
21
21
  rpcCommunicator: ListeningRpcCommunicator
22
22
  }
@@ -40,9 +40,9 @@ export class DeliveryRpcLocal implements IDeliveryRpc {
40
40
 
41
41
  async leaveStreamPartNotice(message: LeaveStreamPartNotice, context: ServerCallContext): Promise<Empty> {
42
42
  if (message.streamPartId === this.config.streamPartId) {
43
- const senderPeerDescriptor = (context as DhtCallContext).incomingSourceDescriptor!
44
- const senderId = getNodeIdFromPeerDescriptor(senderPeerDescriptor)
45
- this.config.onLeaveNotice(senderId)
43
+ const sourcePeerDescriptor = (context as DhtCallContext).incomingSourceDescriptor!
44
+ const sourceId = getNodeIdFromPeerDescriptor(sourcePeerDescriptor)
45
+ this.config.onLeaveNotice(sourceId, message.isEntryPoint)
46
46
  }
47
47
  return Empty
48
48
  }
@@ -4,11 +4,11 @@ import {
4
4
  LeaveStreamPartNotice,
5
5
  StreamMessage
6
6
  } from '../proto/packages/trackerless-network/protos/NetworkRpc'
7
- import { IDeliveryRpcClient } from '../proto/packages/trackerless-network/protos/NetworkRpc.client'
7
+ import { DeliveryRpcClient } from '../proto/packages/trackerless-network/protos/NetworkRpc.client'
8
8
 
9
9
  const logger = new Logger(module)
10
10
 
11
- export class DeliveryRpcRemote extends RpcRemote<IDeliveryRpcClient> {
11
+ export class DeliveryRpcRemote extends RpcRemote<DeliveryRpcClient> {
12
12
 
13
13
  async sendStreamMessage(msg: StreamMessage): Promise<void> {
14
14
  const options = this.formDhtRpcOptions({
@@ -19,9 +19,10 @@ export class DeliveryRpcRemote extends RpcRemote<IDeliveryRpcClient> {
19
19
  })
20
20
  }
21
21
 
22
- leaveStreamPartNotice(): void {
22
+ leaveStreamPartNotice(isLocalNodeEntryPoint: boolean): void {
23
23
  const notification: LeaveStreamPartNotice = {
24
- streamPartId: this.getServiceId()
24
+ streamPartId: this.getServiceId(),
25
+ isEntryPoint: isLocalNodeEntryPoint
25
26
  }
26
27
  const options = this.formDhtRpcOptions({
27
28
  notification: true
@@ -51,7 +51,7 @@ const exponentialRunOff = async (
51
51
 
52
52
  const logger = new Logger(module)
53
53
 
54
- const ENTRYPOINT_STORE_LIMIT = 8
54
+ export const ENTRYPOINT_STORE_LIMIT = 8
55
55
  export const NETWORK_SPLIT_AVOIDANCE_LIMIT = 4
56
56
 
57
57
  interface EntryPointDiscoveryConfig {
@@ -69,16 +69,14 @@ export class EntryPointDiscovery {
69
69
  private readonly config: EntryPointDiscoveryConfig
70
70
  private readonly storeInterval: number
71
71
  private readonly networkSplitAvoidedNodes: Set<NodeID> = new Set()
72
-
72
+ private isLocalNodeStoredAsEntryPoint = false
73
73
  constructor(config: EntryPointDiscoveryConfig) {
74
74
  this.config = config
75
75
  this.abortController = new AbortController()
76
76
  this.storeInterval = this.config.storeInterval ?? 60000
77
77
  }
78
78
 
79
- async discoverEntryPointsFromDht(
80
- knownEntryPointCount: number
81
- ): Promise<FindEntryPointsResult> {
79
+ async discoverEntryPointsFromDht(knownEntryPointCount: number): Promise<FindEntryPointsResult> {
82
80
  if (knownEntryPointCount > 0) {
83
81
  return {
84
82
  entryPointsFromDht: false,
@@ -124,6 +122,7 @@ export class EntryPointDiscovery {
124
122
  }
125
123
  const possibleNetworkSplitDetected = this.config.layer1Node.getNumberOfNeighbors() < NETWORK_SPLIT_AVOIDANCE_LIMIT
126
124
  if ((currentEntrypointCount < ENTRYPOINT_STORE_LIMIT) || possibleNetworkSplitDetected) {
125
+ this.isLocalNodeStoredAsEntryPoint = true
127
126
  await this.storeSelfAsEntryPoint()
128
127
  await this.keepSelfAsEntryPoint()
129
128
  }
@@ -165,7 +164,8 @@ export class EntryPointDiscovery {
165
164
  if (this.config.layer1Node.getNumberOfNeighbors() < NETWORK_SPLIT_AVOIDANCE_LIMIT) {
166
165
  // Filter out nodes that are not neighbors as those nodes are assumed to be offline
167
166
  const nodesToAvoid = rediscoveredEntrypoints
168
- .filter((peer) => !this.config.layer1Node.getAllNeighborPeerDescriptors().includes(peer))
167
+ .filter((peer) => !this.config.layer1Node.getAllNeighborPeerDescriptors()
168
+ .some((neighbor) => areEqualPeerDescriptors(neighbor, peer)))
169
169
  .map((peer) => getNodeIdFromPeerDescriptor(peer))
170
170
  nodesToAvoid.forEach((node) => this.networkSplitAvoidedNodes.add(node))
171
171
  throw new Error(`Network split is still possible`)
@@ -175,6 +175,10 @@ export class EntryPointDiscovery {
175
175
  logger.trace(`Network split avoided`)
176
176
  }
177
177
 
178
+ public isLocalNodeEntryPoint(): boolean {
179
+ return this.isLocalNodeStoredAsEntryPoint
180
+ }
181
+
178
182
  async destroy(): Promise<void> {
179
183
  this.abortController.abort()
180
184
  await this.config.deleteEntryPointData(streamPartIdToDataKey(this.config.streamPartId))
@@ -19,23 +19,24 @@ import { DeliveryRpcRemote } from './DeliveryRpcRemote'
19
19
  import { IDeliveryRpc } from '../proto/packages/trackerless-network/protos/NetworkRpc.server'
20
20
  import { DuplicateMessageDetector } from './DuplicateMessageDetector'
21
21
  import { Logger, addManagedEventListener } from '@streamr/utils'
22
- import { toProtoRpcClient } from '@streamr/proto-rpc'
23
- import { IHandshaker } from './neighbor-discovery/Handshaker'
22
+ import { Handshaker } from './neighbor-discovery/Handshaker'
24
23
  import { Propagation } from './propagation/Propagation'
25
- import { INeighborFinder } from './neighbor-discovery/NeighborFinder'
26
- import { INeighborUpdateManager } from './neighbor-discovery/NeighborUpdateManager'
24
+ import { NeighborFinder } from './neighbor-discovery/NeighborFinder'
25
+ import { NeighborUpdateManager } from './neighbor-discovery/NeighborUpdateManager'
27
26
  import { DeliveryRpcLocal } from './DeliveryRpcLocal'
28
27
  import { ProxyConnectionRpcLocal } from './proxy/ProxyConnectionRpcLocal'
29
- import { IInspector } from './inspect/Inspector'
28
+ import { Inspector } from './inspect/Inspector'
30
29
  import { TemporaryConnectionRpcLocal } from './temporary-connection/TemporaryConnectionRpcLocal'
31
30
  import { markAndCheckDuplicate } from './utils'
32
31
  import { NodeID, getNodeIdFromPeerDescriptor } from '../identifiers'
33
32
  import { Layer1Node } from './Layer1Node'
34
33
  import { StreamPartID } from '@streamr/protocol'
34
+ import { uniqBy } from 'lodash'
35
35
 
36
36
  export interface Events {
37
37
  message: (message: StreamMessage) => void
38
38
  targetNeighborConnected: (nodeId: NodeID) => void
39
+ entryPointLeaveDetected: () => void
39
40
  }
40
41
 
41
42
  export interface StrictRandomGraphNodeConfig {
@@ -48,14 +49,16 @@ export interface StrictRandomGraphNodeConfig {
48
49
  nearbyNodeView: NodeList
49
50
  randomNodeView: NodeList
50
51
  targetNeighbors: NodeList
51
- handshaker: IHandshaker
52
- neighborFinder: INeighborFinder
53
- neighborUpdateManager: INeighborUpdateManager
52
+ handshaker: Handshaker
53
+ neighborFinder: NeighborFinder
54
+ neighborUpdateManager: NeighborUpdateManager
54
55
  propagation: Propagation
55
56
  rpcCommunicator: ListeningRpcCommunicator
56
57
  numOfTargetNeighbors: number
57
- inspector: IInspector
58
+ inspector: Inspector
58
59
  temporaryConnectionRpcLocal: TemporaryConnectionRpcLocal
60
+ isLocalNodeEntryPoint: () => boolean
61
+
59
62
  proxyConnectionRpcLocal?: ProxyConnectionRpcLocal
60
63
  rpcRequestTimeout?: number
61
64
  }
@@ -80,19 +83,25 @@ export class RandomGraphNode extends EventEmitter<Events> {
80
83
  rpcCommunicator: this.config.rpcCommunicator,
81
84
  markAndCheckDuplicate: (msg: MessageID, prev?: MessageRef) => markAndCheckDuplicate(this.duplicateDetectors, msg, prev),
82
85
  broadcast: (message: StreamMessage, previousNode?: NodeID) => this.broadcast(message, previousNode),
83
- onLeaveNotice: (senderId: NodeID) => {
84
- const contact = this.config.nearbyNodeView.get(senderId)
85
- || this.config.randomNodeView.get(senderId)
86
- || this.config.targetNeighbors.get(senderId)
87
- || this.config.proxyConnectionRpcLocal?.getConnection(senderId )?.remote
86
+ onLeaveNotice: (sourceId: NodeID, sourceIsStreamEntryPoint: boolean) => {
87
+ if (this.abortController.signal.aborted) {
88
+ return
89
+ }
90
+ const contact = this.config.nearbyNodeView.get(sourceId)
91
+ || this.config.randomNodeView.get(sourceId)
92
+ || this.config.targetNeighbors.get(sourceId)
93
+ || this.config.proxyConnectionRpcLocal?.getConnection(sourceId )?.remote
88
94
  // TODO: check integrity of notifier?
89
95
  if (contact) {
90
96
  this.config.layer1Node.removeContact(contact.getPeerDescriptor())
91
97
  this.config.targetNeighbors.remove(contact.getPeerDescriptor())
92
98
  this.config.nearbyNodeView.remove(contact.getPeerDescriptor())
93
99
  this.config.connectionLocker.unlockConnection(contact.getPeerDescriptor(), this.config.streamPartId)
94
- this.config.neighborFinder.start([senderId])
95
- this.config.proxyConnectionRpcLocal?.removeConnection(senderId)
100
+ this.config.neighborFinder.start([sourceId])
101
+ this.config.proxyConnectionRpcLocal?.removeConnection(sourceId)
102
+ }
103
+ if (sourceIsStreamEntryPoint) {
104
+ this.emit('entryPointLeaveDetected')
96
105
  }
97
106
  },
98
107
  markForInspection: (senderId: NodeID, messageId: MessageID) => this.config.inspector.markMessage(senderId, messageId)
@@ -191,7 +200,8 @@ export class RandomGraphNode extends EventEmitter<Events> {
191
200
  this.config.localPeerDescriptor,
192
201
  descriptor,
193
202
  this.config.streamPartId,
194
- toProtoRpcClient(new DeliveryRpcClient(this.config.rpcCommunicator.getRpcClientTransport())),
203
+ this.config.rpcCommunicator,
204
+ DeliveryRpcClient,
195
205
  this.config.rpcRequestTimeout
196
206
  )
197
207
  ))
@@ -204,7 +214,8 @@ export class RandomGraphNode extends EventEmitter<Events> {
204
214
  this.config.localPeerDescriptor,
205
215
  descriptor,
206
216
  this.config.streamPartId,
207
- toProtoRpcClient(new DeliveryRpcClient(this.config.rpcCommunicator.getRpcClientTransport())),
217
+ this.config.rpcCommunicator,
218
+ DeliveryRpcClient,
208
219
  this.config.rpcRequestTimeout
209
220
 
210
221
  )
@@ -221,7 +232,8 @@ export class RandomGraphNode extends EventEmitter<Events> {
221
232
  this.config.localPeerDescriptor,
222
233
  descriptor,
223
234
  this.config.streamPartId,
224
- toProtoRpcClient(new DeliveryRpcClient(this.config.rpcCommunicator.getRpcClientTransport())),
235
+ this.config.rpcCommunicator,
236
+ DeliveryRpcClient,
225
237
  this.config.rpcRequestTimeout
226
238
  )
227
239
  ))
@@ -240,7 +252,8 @@ export class RandomGraphNode extends EventEmitter<Events> {
240
252
  this.config.localPeerDescriptor,
241
253
  descriptor,
242
254
  this.config.streamPartId,
243
- toProtoRpcClient(new DeliveryRpcClient(this.config.rpcCommunicator.getRpcClientTransport())),
255
+ this.config.rpcCommunicator,
256
+ DeliveryRpcClient,
244
257
  this.config.rpcRequestTimeout
245
258
  )
246
259
  ))
@@ -256,14 +269,14 @@ export class RandomGraphNode extends EventEmitter<Events> {
256
269
  }
257
270
 
258
271
  private getNeighborCandidatesFromLayer1(): PeerDescriptor[] {
259
- const uniqueNodes = new Set<PeerDescriptor>()
272
+ const nodes: PeerDescriptor[] = []
260
273
  this.config.layer1Node.getClosestContacts(this.config.nodeViewSize).forEach((peer: PeerDescriptor) => {
261
- uniqueNodes.add(peer)
274
+ nodes.push(peer)
262
275
  })
263
276
  this.config.layer1Node.getAllNeighborPeerDescriptors().forEach((peer: PeerDescriptor) => {
264
- uniqueNodes.add(peer)
277
+ nodes.push(peer)
265
278
  })
266
- return Array.from(uniqueNodes)
279
+ return uniqBy(nodes, (p) => getNodeIdFromPeerDescriptor(p))
267
280
  }
268
281
 
269
282
  hasProxyConnection(nodeId: NodeID): boolean {
@@ -279,7 +292,7 @@ export class RandomGraphNode extends EventEmitter<Events> {
279
292
  }
280
293
  this.abortController.abort()
281
294
  this.config.proxyConnectionRpcLocal?.stop()
282
- this.config.targetNeighbors.getAll().map((remote) => remote.leaveStreamPartNotice())
295
+ this.config.targetNeighbors.getAll().map((remote) => remote.leaveStreamPartNotice(this.config.isLocalNodeEntryPoint()))
283
296
  this.config.rpcCommunicator.destroy()
284
297
  this.removeAllListeners()
285
298
  this.config.nearbyNodeView.stop()
@@ -130,7 +130,6 @@ export class StreamrNode extends EventEmitter<Events> {
130
130
  return
131
131
  }
132
132
  const layer1Node = this.createLayer1Node(streamPartId, this.knownStreamPartEntryPoints.get(streamPartId) ?? [])
133
- const node = this.createRandomGraphNode(streamPartId, layer1Node)
134
133
  const entryPointDiscovery = new EntryPointDiscovery({
135
134
  streamPartId,
136
135
  localPeerDescriptor: this.getPeerDescriptor(),
@@ -139,6 +138,11 @@ export class StreamrNode extends EventEmitter<Events> {
139
138
  storeEntryPointData: (key, data) => this.layer0Node!.storeDataToDht(key, data),
140
139
  deleteEntryPointData: async (key: Uint8Array) => this.layer0Node!.deleteDataFromDht(key, false)
141
140
  })
141
+ const node = this.createRandomGraphNode(
142
+ streamPartId,
143
+ layer1Node,
144
+ () => entryPointDiscovery.isLocalNodeEntryPoint()
145
+ )
142
146
  streamPart = {
143
147
  proxied: false,
144
148
  layer1Node,
@@ -155,6 +159,14 @@ export class StreamrNode extends EventEmitter<Events> {
155
159
  node.on('message', (message: StreamMessage) => {
156
160
  this.emit('newMessage', message)
157
161
  })
162
+ const handleEntryPointLeave = async () => {
163
+ if (this.destroyed || entryPointDiscovery.isLocalNodeEntryPoint() || this.knownStreamPartEntryPoints.has(streamPartId)) {
164
+ return
165
+ }
166
+ const entryPoints = await entryPointDiscovery.discoverEntryPointsFromDht(0)
167
+ await entryPointDiscovery.storeSelfAsEntryPointIfNecessary(entryPoints.discoveredEntryPoints.length)
168
+ }
169
+ node.on('entryPointLeaveDetected', () => handleEntryPointLeave())
158
170
  setImmediate(async () => {
159
171
  try {
160
172
  await this.startLayersAndJoinDht(streamPartId, entryPointDiscovery)
@@ -190,13 +202,17 @@ export class StreamrNode extends EventEmitter<Events> {
190
202
  serviceId: 'layer1::' + streamPartId,
191
203
  peerDescriptor: this.layer0Node!.getLocalPeerDescriptor(),
192
204
  entryPoints,
193
- numberOfNodesPerKBucket: 4,
205
+ numberOfNodesPerKBucket: 4, // TODO use config option or named constant?
194
206
  rpcRequestTimeout: EXISTING_CONNECTION_TIMEOUT,
195
- dhtJoinTimeout: 20000
207
+ dhtJoinTimeout: 20000 // TODO use config option or named constant?
196
208
  })
197
209
  }
198
210
 
199
- private createRandomGraphNode(streamPartId: StreamPartID, layer1Node: Layer1Node) {
211
+ private createRandomGraphNode(
212
+ streamPartId: StreamPartID,
213
+ layer1Node: Layer1Node,
214
+ isLocalNodeEntryPoint: () => boolean
215
+ ) {
200
216
  return createRandomGraphNode({
201
217
  streamPartId,
202
218
  transport: this.transport!,
@@ -206,7 +222,8 @@ export class StreamrNode extends EventEmitter<Events> {
206
222
  minPropagationTargets: this.config.streamPartitionMinPropagationTargets,
207
223
  numOfTargetNeighbors: this.config.streamPartitionNumOfNeighbors,
208
224
  acceptProxyConnections: this.config.acceptProxyConnections,
209
- rpcRequestTimeout: this.config.rpcRequestTimeout
225
+ rpcRequestTimeout: this.config.rpcRequestTimeout,
226
+ isLocalNodeEntryPoint
210
227
  })
211
228
  }
212
229
 
@@ -1,5 +1,6 @@
1
+ import { ServiceID } from '@streamr/dht'
1
2
  import { StreamPartID } from '@streamr/protocol'
2
3
 
3
- export const formStreamPartDeliveryServiceId = (streamPartId: StreamPartID): string => {
4
+ export const formStreamPartDeliveryServiceId = (streamPartId: StreamPartID): ServiceID => {
4
5
  return `stream-part-delivery-${streamPartId}`
5
6
  }