@streamr/trackerless-network 101.0.0-beta.2 → 101.0.0-beta.4

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 (133) hide show
  1. package/dist/package.json +5 -6
  2. package/dist/src/NetworkNode.d.ts +5 -7
  3. package/dist/src/NetworkNode.js +5 -24
  4. package/dist/src/NetworkNode.js.map +1 -1
  5. package/dist/src/NetworkStack.d.ts +1 -2
  6. package/dist/src/NetworkStack.js +1 -2
  7. package/dist/src/NetworkStack.js.map +1 -1
  8. package/dist/src/exports.d.ts +3 -5
  9. package/dist/src/exports.js +13 -13
  10. package/dist/src/exports.js.map +1 -1
  11. package/dist/src/logic/ContentDeliveryLayerNode.d.ts +5 -5
  12. package/dist/src/logic/ContentDeliveryLayerNode.js +3 -3
  13. package/dist/src/logic/ContentDeliveryLayerNode.js.map +1 -1
  14. package/dist/src/logic/ContentDeliveryManager.d.ts +1 -2
  15. package/dist/src/logic/ContentDeliveryManager.js +2 -3
  16. package/dist/src/logic/ContentDeliveryManager.js.map +1 -1
  17. package/dist/src/logic/ContentDeliveryRpcLocal.d.ts +3 -3
  18. package/dist/src/logic/ContentDeliveryRpcLocal.js.map +1 -1
  19. package/dist/src/logic/ContentDeliveryRpcRemote.d.ts +1 -1
  20. package/dist/src/logic/ContentDeliveryRpcRemote.js.map +1 -1
  21. package/dist/src/logic/createContentDeliveryLayerNode.d.ts +1 -1
  22. package/dist/src/logic/formStreamPartDeliveryServiceId.d.ts +1 -1
  23. package/dist/src/logic/inspect/Inspector.d.ts +2 -2
  24. package/dist/src/logic/inspect/Inspector.js +2 -2
  25. package/dist/src/logic/inspect/Inspector.js.map +1 -1
  26. package/dist/src/logic/neighbor-discovery/HandshakeRpcLocal.d.ts +4 -4
  27. package/dist/src/logic/neighbor-discovery/HandshakeRpcLocal.js.map +1 -1
  28. package/dist/src/logic/neighbor-discovery/HandshakeRpcRemote.d.ts +1 -1
  29. package/dist/src/logic/neighbor-discovery/HandshakeRpcRemote.js.map +1 -1
  30. package/dist/src/logic/neighbor-discovery/Handshaker.d.ts +2 -2
  31. package/dist/src/logic/neighbor-discovery/Handshaker.js +4 -4
  32. package/dist/src/logic/neighbor-discovery/Handshaker.js.map +1 -1
  33. package/dist/src/logic/neighbor-discovery/NeighborUpdateManager.d.ts +2 -2
  34. package/dist/src/logic/neighbor-discovery/NeighborUpdateManager.js +3 -3
  35. package/dist/src/logic/neighbor-discovery/NeighborUpdateManager.js.map +1 -1
  36. package/dist/src/logic/neighbor-discovery/NeighborUpdateRpcLocal.d.ts +1 -1
  37. package/dist/src/logic/neighbor-discovery/NeighborUpdateRpcLocal.js.map +1 -1
  38. package/dist/src/logic/neighbor-discovery/NeighborUpdateRpcRemote.d.ts +1 -1
  39. package/dist/src/logic/neighbor-discovery/NeighborUpdateRpcRemote.js.map +1 -1
  40. package/dist/src/logic/proxy/ProxyClient.d.ts +1 -2
  41. package/dist/src/logic/proxy/ProxyClient.js +3 -3
  42. package/dist/src/logic/proxy/ProxyClient.js.map +1 -1
  43. package/dist/src/logic/proxy/ProxyConnectionRpcLocal.d.ts +3 -4
  44. package/dist/src/logic/proxy/ProxyConnectionRpcLocal.js +4 -4
  45. package/dist/src/logic/proxy/ProxyConnectionRpcLocal.js.map +1 -1
  46. package/dist/src/logic/temporary-connection/TemporaryConnectionRpcLocal.d.ts +4 -4
  47. package/dist/src/logic/temporary-connection/TemporaryConnectionRpcLocal.js +1 -1
  48. package/dist/src/logic/temporary-connection/TemporaryConnectionRpcLocal.js.map +1 -1
  49. package/dist/test/benchmark/first-message.js +23 -12
  50. package/dist/test/benchmark/first-message.js.map +1 -1
  51. package/dist/test/utils/utils.d.ts +4 -5
  52. package/dist/test/utils/utils.js +6 -7
  53. package/dist/test/utils/utils.js.map +1 -1
  54. package/package.json +5 -6
  55. package/src/NetworkNode.ts +7 -25
  56. package/src/NetworkStack.ts +1 -2
  57. package/src/exports.ts +14 -11
  58. package/src/logic/ContentDeliveryLayerNode.ts +13 -14
  59. package/src/logic/ContentDeliveryManager.ts +1 -2
  60. package/src/logic/ContentDeliveryRpcLocal.ts +3 -3
  61. package/src/logic/ContentDeliveryRpcRemote.ts +1 -2
  62. package/src/logic/createContentDeliveryLayerNode.ts +1 -1
  63. package/src/logic/formStreamPartDeliveryServiceId.ts +1 -1
  64. package/src/logic/inspect/Inspector.ts +3 -4
  65. package/src/logic/neighbor-discovery/HandshakeRpcLocal.ts +9 -10
  66. package/src/logic/neighbor-discovery/HandshakeRpcRemote.ts +1 -2
  67. package/src/logic/neighbor-discovery/Handshaker.ts +8 -9
  68. package/src/logic/neighbor-discovery/NeighborUpdateManager.ts +4 -5
  69. package/src/logic/neighbor-discovery/NeighborUpdateRpcLocal.ts +2 -2
  70. package/src/logic/neighbor-discovery/NeighborUpdateRpcRemote.ts +1 -2
  71. package/src/logic/proxy/ProxyClient.ts +4 -5
  72. package/src/logic/proxy/ProxyConnectionRpcLocal.ts +5 -6
  73. package/src/logic/temporary-connection/TemporaryConnectionRpcLocal.ts +7 -7
  74. package/test/benchmark/StreamPartIdDataKeyDistribution.test.ts +2 -2
  75. package/test/benchmark/first-message.ts +28 -29
  76. package/test/end-to-end/content-delivery-layer-node-with-real-connections.test.ts +4 -5
  77. package/test/end-to-end/inspect.test.ts +26 -28
  78. package/test/end-to-end/proxy-and-full-node.test.ts +34 -32
  79. package/test/end-to-end/proxy-connections.test.ts +34 -31
  80. package/test/end-to-end/proxy-key-exchange.test.ts +41 -57
  81. package/test/end-to-end/webrtc-full-node-network.test.ts +1 -2
  82. package/test/end-to-end/websocket-full-node-network.test.ts +2 -3
  83. package/test/integration/ContentDeliveryLayerNode-Layer1Node-Latencies.test.ts +2 -3
  84. package/test/integration/ContentDeliveryLayerNode-Layer1Node.test.ts +2 -3
  85. package/test/integration/ContentDeliveryManager.test.ts +3 -4
  86. package/test/integration/ContentDeliveryRpcRemote.test.ts +7 -8
  87. package/test/integration/HandshakeRpcRemote.test.ts +6 -6
  88. package/test/integration/Handshakes.test.ts +6 -6
  89. package/test/integration/Inspect.test.ts +1 -1
  90. package/test/integration/NeighborUpdateRpcRemote.test.ts +1 -1
  91. package/test/integration/NetworkNode.test.ts +28 -29
  92. package/test/integration/NetworkRpc.test.ts +7 -8
  93. package/test/integration/NetworkStack.test.ts +4 -4
  94. package/test/integration/NodeInfoRpc.test.ts +3 -4
  95. package/test/integration/Propagation.test.ts +2 -3
  96. package/test/integration/joining-streams-on-offline-peers.test.ts +3 -4
  97. package/test/integration/stream-without-default-entrypoints.test.ts +26 -28
  98. package/test/integration/streamEntryPointReplacing.test.ts +5 -6
  99. package/test/unit/ContentDeliveryLayerNode.test.ts +5 -6
  100. package/test/unit/ContentDeliveryManager.test.ts +2 -3
  101. package/test/unit/ContentDeliveryRpcLocal.test.ts +1 -1
  102. package/test/unit/HandshakeRpcLocal.test.ts +2 -2
  103. package/test/unit/Handshaker.test.ts +2 -2
  104. package/test/unit/Inspector.test.ts +1 -2
  105. package/test/unit/NeighborUpdateRpcLocal.test.ts +6 -6
  106. package/test/unit/NetworkNode.test.ts +3 -4
  107. package/test/unit/NodeList.test.ts +2 -2
  108. package/test/unit/StreamPartIDDataKey.test.ts +1 -1
  109. package/test/unit/StreamPartNetworkSplitAvoidance.test.ts +1 -2
  110. package/test/unit/TemporaryConnectionRpcLocal.test.ts +2 -2
  111. package/test/utils/mock/MockTransport.ts +1 -2
  112. package/test/utils/utils.ts +8 -9
  113. package/tsconfig.jest.json +0 -1
  114. package/tsconfig.node.json +0 -2
  115. package/dist/src/logic/protocol-integration/stream-message/GroupKeyRequestTranslator.d.ts +0 -6
  116. package/dist/src/logic/protocol-integration/stream-message/GroupKeyRequestTranslator.js +0 -28
  117. package/dist/src/logic/protocol-integration/stream-message/GroupKeyRequestTranslator.js.map +0 -1
  118. package/dist/src/logic/protocol-integration/stream-message/GroupKeyResponseTranslator.d.ts +0 -6
  119. package/dist/src/logic/protocol-integration/stream-message/GroupKeyResponseTranslator.js +0 -32
  120. package/dist/src/logic/protocol-integration/stream-message/GroupKeyResponseTranslator.js.map +0 -1
  121. package/dist/src/logic/protocol-integration/stream-message/StreamMessageTranslator.d.ts +0 -6
  122. package/dist/src/logic/protocol-integration/stream-message/StreamMessageTranslator.js +0 -170
  123. package/dist/src/logic/protocol-integration/stream-message/StreamMessageTranslator.js.map +0 -1
  124. package/dist/src/logic/protocol-integration/stream-message/oldStreamMessageBinaryUtils.d.ts +0 -7
  125. package/dist/src/logic/protocol-integration/stream-message/oldStreamMessageBinaryUtils.js +0 -32
  126. package/dist/src/logic/protocol-integration/stream-message/oldStreamMessageBinaryUtils.js.map +0 -1
  127. package/src/logic/protocol-integration/stream-message/GroupKeyRequestTranslator.ts +0 -28
  128. package/src/logic/protocol-integration/stream-message/GroupKeyResponseTranslator.ts +0 -34
  129. package/src/logic/protocol-integration/stream-message/StreamMessageTranslator.ts +0 -197
  130. package/src/logic/protocol-integration/stream-message/oldStreamMessageBinaryUtils.ts +0 -37
  131. package/test/unit/GroupKeyResponseTranslator.test.ts +0 -39
  132. package/test/unit/StreamMessageTranslator.test.ts +0 -71
  133. package/test/unit/oldStreamMessageBinaryUtils.test.ts +0 -39
package/src/exports.ts CHANGED
@@ -1,13 +1,16 @@
1
- export { NetworkStack, NetworkOptions, NodeInfo } from './NetworkStack'
2
1
  export { NetworkNode, createNetworkNode } from './NetworkNode'
3
- export { ContentDeliveryManagerOptions } from './logic/ContentDeliveryManager'
4
- export { ProxyDirection, GroupKeyRequest, GroupKeyResponse } from './proto/packages/trackerless-network/protos/NetworkRpc'
5
- export { streamPartIdToDataKey } from './logic/ContentDeliveryManager'
2
+ export { NetworkOptions, NetworkStack, NodeInfo } from './NetworkStack'
3
+ export { ContentDeliveryManagerOptions, streamPartIdToDataKey } from './logic/ContentDeliveryManager'
6
4
  export {
7
- convertStreamMessageToBytes,
8
- convertBytesToStreamMessage,
9
- convertGroupKeyRequestToBytes,
10
- convertBytesToGroupKeyRequest,
11
- convertGroupKeyResponseToBytes,
12
- convertBytesToGroupKeyResponse
13
- } from './logic/protocol-integration/stream-message/oldStreamMessageBinaryUtils'
5
+ ContentType,
6
+ EncryptionType,
7
+ GroupKey,
8
+ GroupKeyRequest,
9
+ GroupKeyResponse,
10
+ MessageID,
11
+ MessageRef,
12
+ ProxyDirection,
13
+ SignatureType,
14
+ StreamMessage
15
+ } from './proto/packages/trackerless-network/protos/NetworkRpc'
16
+
@@ -1,37 +1,36 @@
1
- import { EventEmitter } from 'eventemitter3'
2
1
  import {
3
- PeerDescriptor,
4
- ListeningRpcCommunicator,
5
- ITransport,
6
2
  ConnectionLocker,
7
3
  DhtAddress,
4
+ ITransport,
5
+ ListeningRpcCommunicator,
6
+ PeerDescriptor,
8
7
  getNodeIdFromPeerDescriptor,
9
8
  } from '@streamr/dht'
9
+ import { Logger, StreamPartID, addManagedEventListener } from '@streamr/utils'
10
+ import { EventEmitter } from 'eventemitter3'
10
11
  import {
11
- StreamMessage,
12
+ CloseTemporaryConnection,
12
13
  LeaveStreamPartNotice,
14
+ MessageID,
13
15
  MessageRef,
16
+ StreamMessage,
14
17
  TemporaryConnectionRequest,
15
18
  TemporaryConnectionResponse,
16
- MessageID,
17
- CloseTemporaryConnection,
18
19
  } from '../proto/packages/trackerless-network/protos/NetworkRpc'
19
- import { NodeList } from './NodeList'
20
20
  import { ContentDeliveryRpcClient } from '../proto/packages/trackerless-network/protos/NetworkRpc.client'
21
+ import { ContentDeliveryRpcLocal } from './ContentDeliveryRpcLocal'
21
22
  import { ContentDeliveryRpcRemote } from './ContentDeliveryRpcRemote'
23
+ import { DiscoveryLayerNode } from './DiscoveryLayerNode'
22
24
  import { DuplicateMessageDetector } from './DuplicateMessageDetector'
23
- import { Logger, addManagedEventListener } from '@streamr/utils'
25
+ import { NodeList } from './NodeList'
26
+ import { Inspector } from './inspect/Inspector'
24
27
  import { Handshaker } from './neighbor-discovery/Handshaker'
25
- import { Propagation } from './propagation/Propagation'
26
28
  import { NeighborFinder } from './neighbor-discovery/NeighborFinder'
27
29
  import { NeighborUpdateManager } from './neighbor-discovery/NeighborUpdateManager'
28
- import { ContentDeliveryRpcLocal } from './ContentDeliveryRpcLocal'
30
+ import { Propagation } from './propagation/Propagation'
29
31
  import { ProxyConnectionRpcLocal } from './proxy/ProxyConnectionRpcLocal'
30
- import { Inspector } from './inspect/Inspector'
31
32
  import { TemporaryConnectionRpcLocal } from './temporary-connection/TemporaryConnectionRpcLocal'
32
33
  import { markAndCheckDuplicate } from './utils'
33
- import { DiscoveryLayerNode } from './DiscoveryLayerNode'
34
- import { StreamPartID } from '@streamr/protocol'
35
34
 
36
35
  export interface Events {
37
36
  message: (message: StreamMessage) => void
@@ -8,14 +8,13 @@ import {
8
8
  getDhtAddressFromRaw,
9
9
  getNodeIdFromPeerDescriptor
10
10
  } from '@streamr/dht'
11
- import { StreamID, StreamPartID, StreamPartIDUtils, toStreamPartID } from '@streamr/protocol'
12
11
  import {
13
12
  EthereumAddress,
14
13
  Logger,
15
14
  Metric,
16
15
  MetricsContext,
17
16
  MetricsDefinition,
18
- RateMetric
17
+ RateMetric, StreamID, StreamPartID, StreamPartIDUtils, toStreamPartID
19
18
  } from '@streamr/utils'
20
19
  import { createHash } from 'crypto'
21
20
  import { EventEmitter } from 'eventemitter3'
@@ -1,4 +1,6 @@
1
- import { ListeningRpcCommunicator, PeerDescriptor, DhtCallContext, DhtAddress, getNodeIdFromPeerDescriptor } from '@streamr/dht'
1
+ import { ServerCallContext } from '@protobuf-ts/runtime-rpc'
2
+ import { DhtAddress, DhtCallContext, ListeningRpcCommunicator, PeerDescriptor, getNodeIdFromPeerDescriptor } from '@streamr/dht'
3
+ import { StreamPartID } from '@streamr/utils'
2
4
  import { Empty } from '../proto/google/protobuf/empty'
3
5
  import {
4
6
  LeaveStreamPartNotice,
@@ -7,8 +9,6 @@ import {
7
9
  StreamMessage
8
10
  } from '../proto/packages/trackerless-network/protos/NetworkRpc'
9
11
  import { IContentDeliveryRpc } from '../proto/packages/trackerless-network/protos/NetworkRpc.server'
10
- import { ServerCallContext } from '@protobuf-ts/runtime-rpc'
11
- import { StreamPartID } from '@streamr/protocol'
12
12
 
13
13
  export interface ContentDeliveryRpcLocalOptions {
14
14
  localPeerDescriptor: PeerDescriptor
@@ -1,11 +1,10 @@
1
1
  import { RpcRemote } from '@streamr/dht'
2
- import { Logger } from '@streamr/utils'
2
+ import { Logger, StreamPartID } from '@streamr/utils'
3
3
  import {
4
4
  LeaveStreamPartNotice,
5
5
  StreamMessage
6
6
  } from '../proto/packages/trackerless-network/protos/NetworkRpc'
7
7
  import { ContentDeliveryRpcClient } from '../proto/packages/trackerless-network/protos/NetworkRpc.client'
8
- import { StreamPartID } from '@streamr/protocol'
9
8
 
10
9
  const logger = new Logger(module)
11
10
 
@@ -6,7 +6,7 @@ import { StrictContentDeliveryLayerNodeOptions, ContentDeliveryLayerNode } from
6
6
  import { NodeList } from './NodeList'
7
7
  import { Propagation } from './propagation/Propagation'
8
8
  import { StreamMessage } from '../proto/packages/trackerless-network/protos/NetworkRpc'
9
- import { MarkOptional } from 'ts-essentials'
9
+ import type { MarkOptional } from 'ts-essentials'
10
10
  import { ProxyConnectionRpcLocal } from './proxy/ProxyConnectionRpcLocal'
11
11
  import { Inspector } from './inspect/Inspector'
12
12
  import { TemporaryConnectionRpcLocal } from './temporary-connection/TemporaryConnectionRpcLocal'
@@ -1,5 +1,5 @@
1
1
  import { ServiceID } from '@streamr/dht'
2
- import { StreamPartID } from '@streamr/protocol'
2
+ import { StreamPartID } from '@streamr/utils'
3
3
 
4
4
  export const formStreamPartContentDeliveryServiceId = (streamPartId: StreamPartID): ServiceID => {
5
5
  // could be "content-delivery" instead of "delivery", but that is a breaking change
@@ -1,10 +1,9 @@
1
- import { PeerDescriptor, ConnectionLocker, LockID, DhtAddress, getNodeIdFromPeerDescriptor, ListeningRpcCommunicator } from '@streamr/dht'
1
+ import { ConnectionLocker, DhtAddress, ListeningRpcCommunicator, LockID, PeerDescriptor, getNodeIdFromPeerDescriptor } from '@streamr/dht'
2
+ import { Logger, StreamPartID, waitForEvent3 } from '@streamr/utils'
2
3
  import { MessageID } from '../../proto/packages/trackerless-network/protos/NetworkRpc'
3
- import { InspectSession, Events as InspectSessionEvents } from './InspectSession'
4
4
  import { TemporaryConnectionRpcClient } from '../../proto/packages/trackerless-network/protos/NetworkRpc.client'
5
- import { Logger, waitForEvent3 } from '@streamr/utils'
6
5
  import { TemporaryConnectionRpcRemote } from '../temporary-connection/TemporaryConnectionRpcRemote'
7
- import { StreamPartID } from '@streamr/protocol'
6
+ import { InspectSession, Events as InspectSessionEvents } from './InspectSession'
8
7
 
9
8
  interface InspectorOptions {
10
9
  localPeerDescriptor: PeerDescriptor
@@ -1,11 +1,4 @@
1
- import {
2
- InterleaveRequest,
3
- InterleaveResponse,
4
- StreamPartHandshakeRequest,
5
- StreamPartHandshakeResponse
6
- } from '../../proto/packages/trackerless-network/protos/NetworkRpc'
7
1
  import { ServerCallContext } from '@protobuf-ts/runtime-rpc'
8
- import { NodeList } from '../NodeList'
9
2
  import {
10
3
  DhtAddress,
11
4
  DhtAddressRaw,
@@ -14,11 +7,17 @@ import {
14
7
  getDhtAddressFromRaw,
15
8
  getNodeIdFromPeerDescriptor
16
9
  } from '@streamr/dht'
10
+ import { Logger, StreamPartID } from '@streamr/utils'
11
+ import {
12
+ InterleaveRequest,
13
+ InterleaveResponse,
14
+ StreamPartHandshakeRequest,
15
+ StreamPartHandshakeResponse
16
+ } from '../../proto/packages/trackerless-network/protos/NetworkRpc'
17
17
  import { IHandshakeRpc } from '../../proto/packages/trackerless-network/protos/NetworkRpc.server'
18
- import { HandshakeRpcRemote } from './HandshakeRpcRemote'
19
18
  import { ContentDeliveryRpcRemote } from '../ContentDeliveryRpcRemote'
20
- import { Logger } from '@streamr/utils'
21
- import { StreamPartID } from '@streamr/protocol'
19
+ import { NodeList } from '../NodeList'
20
+ import { HandshakeRpcRemote } from './HandshakeRpcRemote'
22
21
 
23
22
  interface HandshakeRpcLocalOptions {
24
23
  streamPartId: StreamPartID
@@ -1,9 +1,8 @@
1
1
  import { DhtAddress, PeerDescriptor, RpcRemote, getNodeIdFromPeerDescriptor, getRawFromDhtAddress } from '@streamr/dht'
2
- import { Logger } from '@streamr/utils'
2
+ import { Logger, StreamPartID } from '@streamr/utils'
3
3
  import { v4 } from 'uuid'
4
4
  import { InterleaveRequest, InterleaveResponse, StreamPartHandshakeRequest } from '../../proto/packages/trackerless-network/protos/NetworkRpc'
5
5
  import { HandshakeRpcClient } from '../../proto/packages/trackerless-network/protos/NetworkRpc.client'
6
- import { StreamPartID } from '@streamr/protocol'
7
6
 
8
7
  const logger = new Logger(module)
9
8
 
@@ -1,19 +1,18 @@
1
- import { DhtAddress, PeerDescriptor, ListeningRpcCommunicator, getNodeIdFromPeerDescriptor } from '@streamr/dht'
2
- import { NodeList } from '../NodeList'
3
- import { ContentDeliveryRpcRemote } from '../ContentDeliveryRpcRemote'
4
- import {
5
- ContentDeliveryRpcClient, HandshakeRpcClient
6
- } from '../../proto/packages/trackerless-network/protos/NetworkRpc.client'
1
+ import { DhtAddress, ListeningRpcCommunicator, PeerDescriptor, getNodeIdFromPeerDescriptor } from '@streamr/dht'
2
+ import { Logger, StreamPartID } from '@streamr/utils'
7
3
  import {
8
4
  InterleaveRequest,
9
5
  InterleaveResponse,
10
6
  StreamPartHandshakeRequest,
11
7
  StreamPartHandshakeResponse
12
8
  } from '../../proto/packages/trackerless-network/protos/NetworkRpc'
13
- import { Logger } from '@streamr/utils'
14
- import { HandshakeRpcRemote, INTERLEAVE_REQUEST_TIMEOUT } from './HandshakeRpcRemote'
9
+ import {
10
+ ContentDeliveryRpcClient, HandshakeRpcClient
11
+ } from '../../proto/packages/trackerless-network/protos/NetworkRpc.client'
12
+ import { ContentDeliveryRpcRemote } from '../ContentDeliveryRpcRemote'
13
+ import { NodeList } from '../NodeList'
15
14
  import { HandshakeRpcLocal } from './HandshakeRpcLocal'
16
- import { StreamPartID } from '@streamr/protocol'
15
+ import { HandshakeRpcRemote, INTERLEAVE_REQUEST_TIMEOUT } from './HandshakeRpcRemote'
17
16
 
18
17
  interface HandshakerOptions {
19
18
  localPeerDescriptor: PeerDescriptor
@@ -1,12 +1,11 @@
1
- import { NeighborUpdate } from '../../proto/packages/trackerless-network/protos/NetworkRpc'
2
1
  import { DhtAddress, ListeningRpcCommunicator, PeerDescriptor, getNodeIdFromPeerDescriptor } from '@streamr/dht'
2
+ import { Logger, StreamPartID, scheduleAtInterval } from '@streamr/utils'
3
+ import { NeighborUpdate } from '../../proto/packages/trackerless-network/protos/NetworkRpc'
3
4
  import { NeighborUpdateRpcClient } from '../../proto/packages/trackerless-network/protos/NetworkRpc.client'
4
- import { Logger, scheduleAtInterval } from '@streamr/utils'
5
- import { NeighborFinder } from './NeighborFinder'
6
5
  import { NodeList } from '../NodeList'
7
- import { NeighborUpdateRpcRemote } from './NeighborUpdateRpcRemote'
6
+ import { NeighborFinder } from './NeighborFinder'
8
7
  import { NeighborUpdateRpcLocal } from './NeighborUpdateRpcLocal'
9
- import { StreamPartID } from '@streamr/protocol'
8
+ import { NeighborUpdateRpcRemote } from './NeighborUpdateRpcRemote'
10
9
 
11
10
  interface NeighborUpdateManagerOptions {
12
11
  localPeerDescriptor: PeerDescriptor
@@ -1,12 +1,12 @@
1
1
  import { ServerCallContext } from '@protobuf-ts/runtime-rpc'
2
2
  import { DhtAddress, DhtCallContext, ListeningRpcCommunicator, PeerDescriptor, getNodeIdFromPeerDescriptor } from '@streamr/dht'
3
+ import { StreamPartID } from '@streamr/utils'
3
4
  import { NeighborUpdate } from '../../proto/packages/trackerless-network/protos/NetworkRpc'
4
5
  import { ContentDeliveryRpcClient } from '../../proto/packages/trackerless-network/protos/NetworkRpc.client'
5
6
  import { INeighborUpdateRpc } from '../../proto/packages/trackerless-network/protos/NetworkRpc.server'
6
- import { NodeList } from '../NodeList'
7
7
  import { ContentDeliveryRpcRemote } from '../ContentDeliveryRpcRemote'
8
+ import { NodeList } from '../NodeList'
8
9
  import { NeighborFinder } from './NeighborFinder'
9
- import { StreamPartID } from '@streamr/protocol'
10
10
 
11
11
  interface NeighborUpdateRpcLocalOptions {
12
12
  localPeerDescriptor: PeerDescriptor
@@ -1,8 +1,7 @@
1
1
  import { PeerDescriptor, RpcRemote, getNodeIdFromPeerDescriptor } from '@streamr/dht'
2
- import { Logger } from '@streamr/utils'
2
+ import { Logger, StreamPartID } from '@streamr/utils'
3
3
  import { NeighborUpdate } from '../../proto/packages/trackerless-network/protos/NetworkRpc'
4
4
  import { NeighborUpdateRpcClient } from '../../proto/packages/trackerless-network/protos/NetworkRpc.client'
5
- import { StreamPartID } from '@streamr/protocol'
6
5
 
7
6
  const logger = new Logger(module)
8
7
 
@@ -6,8 +6,7 @@ import {
6
6
  PeerDescriptor,
7
7
  getNodeIdFromPeerDescriptor
8
8
  } from '@streamr/dht'
9
- import { StreamPartID } from '@streamr/protocol'
10
- import { EthereumAddress, Logger, addManagedEventListener, wait } from '@streamr/utils'
9
+ import { EthereumAddress, Logger, StreamPartID, addManagedEventListener, wait } from '@streamr/utils'
11
10
  import { EventEmitter } from 'eventemitter3'
12
11
  import { sampleSize } from 'lodash'
13
12
  import {
@@ -18,14 +17,14 @@ import {
18
17
  StreamMessage
19
18
  } from '../../proto/packages/trackerless-network/protos/NetworkRpc'
20
19
  import { ContentDeliveryRpcClient, ProxyConnectionRpcClient } from '../../proto/packages/trackerless-network/protos/NetworkRpc.client'
20
+ import { ContentDeliveryRpcLocal } from '../ContentDeliveryRpcLocal'
21
+ import { ContentDeliveryRpcRemote } from '../ContentDeliveryRpcRemote'
21
22
  import { DuplicateMessageDetector } from '../DuplicateMessageDetector'
22
23
  import { NodeList } from '../NodeList'
23
- import { ContentDeliveryRpcRemote } from '../ContentDeliveryRpcRemote'
24
- import { ContentDeliveryRpcLocal } from '../ContentDeliveryRpcLocal'
24
+ import { formStreamPartContentDeliveryServiceId } from '../formStreamPartDeliveryServiceId'
25
25
  import { Propagation } from '../propagation/Propagation'
26
26
  import { markAndCheckDuplicate } from '../utils'
27
27
  import { ProxyConnectionRpcRemote } from './ProxyConnectionRpcRemote'
28
- import { formStreamPartContentDeliveryServiceId } from '../formStreamPartDeliveryServiceId'
29
28
 
30
29
  // TODO use options option or named constant?
31
30
  export const retry = async <T>(task: () => Promise<T>, description: string, abortSignal: AbortSignal, delay = 10000): Promise<T> => {
@@ -1,17 +1,16 @@
1
1
  import { ServerCallContext } from '@protobuf-ts/runtime-rpc'
2
- import {
2
+ import { DhtAddress, DhtCallContext, ListeningRpcCommunicator, PeerDescriptor, getNodeIdFromPeerDescriptor } from '@streamr/dht'
3
+ import { EthereumAddress, Logger, StreamPartID, binaryToHex, toEthereumAddress } from '@streamr/utils'
4
+ import { EventEmitter } from 'eventemitter3'
5
+ import {
3
6
  ProxyConnectionRequest,
4
7
  ProxyConnectionResponse,
5
8
  ProxyDirection,
6
9
  StreamMessage
7
10
  } from '../../proto/packages/trackerless-network/protos/NetworkRpc'
11
+ import { ContentDeliveryRpcClient } from '../../proto/packages/trackerless-network/protos/NetworkRpc.client'
8
12
  import { IProxyConnectionRpc } from '../../proto/packages/trackerless-network/protos/NetworkRpc.server'
9
13
  import { ContentDeliveryRpcRemote } from '../ContentDeliveryRpcRemote'
10
- import { DhtAddress, DhtCallContext, ListeningRpcCommunicator, PeerDescriptor, getNodeIdFromPeerDescriptor } from '@streamr/dht'
11
- import { ContentDeliveryRpcClient } from '../../proto/packages/trackerless-network/protos/NetworkRpc.client'
12
- import { EventEmitter } from 'eventemitter3'
13
- import { EthereumAddress, Logger, binaryToHex, toEthereumAddress } from '@streamr/utils'
14
- import { StreamPartID } from '@streamr/protocol'
15
14
 
16
15
  const logger = new Logger(module)
17
16
 
@@ -1,17 +1,17 @@
1
1
  import { ServerCallContext } from '@protobuf-ts/runtime-rpc'
2
- import {
2
+ import { ConnectionLocker, DhtAddress, DhtCallContext, ListeningRpcCommunicator, getNodeIdFromPeerDescriptor } from '@streamr/dht'
3
+ import { StreamPartID } from '@streamr/utils'
4
+ import { Empty } from '../../proto/google/protobuf/empty'
5
+ import { PeerDescriptor } from '../../proto/packages/dht/protos/DhtRpc'
6
+ import {
3
7
  CloseTemporaryConnection,
4
8
  TemporaryConnectionRequest,
5
9
  TemporaryConnectionResponse
6
10
  } from '../../proto/packages/trackerless-network/protos/NetworkRpc'
7
- import { ITemporaryConnectionRpc } from '../../proto/packages/trackerless-network/protos/NetworkRpc.server'
8
- import { ConnectionLocker, DhtAddress, DhtCallContext, ListeningRpcCommunicator, getNodeIdFromPeerDescriptor } from '@streamr/dht'
9
11
  import { ContentDeliveryRpcClient } from '../../proto/packages/trackerless-network/protos/NetworkRpc.client'
10
- import { NodeList } from '../NodeList'
12
+ import { ITemporaryConnectionRpc } from '../../proto/packages/trackerless-network/protos/NetworkRpc.server'
11
13
  import { ContentDeliveryRpcRemote } from '../ContentDeliveryRpcRemote'
12
- import { PeerDescriptor } from '../../proto/packages/dht/protos/DhtRpc'
13
- import { Empty } from '../../proto/google/protobuf/empty'
14
- import { StreamPartID } from '@streamr/protocol'
14
+ import { NodeList } from '../NodeList'
15
15
 
16
16
  interface TemporaryConnectionRpcLocalOptions {
17
17
  rpcCommunicator: ListeningRpcCommunicator
@@ -1,9 +1,9 @@
1
1
  /* eslint-disable no-console */
2
2
 
3
+ import { DhtAddress } from '@streamr/dht'
4
+ import { StreamPartIDUtils } from '@streamr/utils'
3
5
  import { groupBy, range } from 'lodash'
4
6
  import { streamPartIdToDataKey } from '../../src/logic/ContentDeliveryManager'
5
- import { StreamPartIDUtils } from '@streamr/protocol'
6
- import { DhtAddress } from '@streamr/dht'
7
7
 
8
8
  describe('StreamPartIdDataKeyDistribution', () => {
9
9
 
@@ -9,24 +9,20 @@ import {
9
9
  Simulator
10
10
  } from '@streamr/dht'
11
11
  import {
12
- ContentType,
13
- EncryptionType,
14
- MessageID,
15
- SignatureType,
16
- StreamMessage,
17
- StreamMessageType,
12
+ hexToBinary,
18
13
  StreamPartID,
19
14
  StreamPartIDUtils,
20
15
  toStreamID,
21
- toStreamPartID
22
- } from '@streamr/protocol'
23
- import { hexToBinary, utf8ToBinary, waitForEvent3 } from '@streamr/utils'
16
+ toStreamPartID,
17
+ utf8ToBinary, waitForEvent3
18
+ } from '@streamr/utils'
24
19
  import fs from 'fs'
25
- import { NetworkNode } from '../../src/NetworkNode'
20
+ import { ContentDeliveryLayerNode } from '../../src/logic/ContentDeliveryLayerNode'
26
21
  import { streamPartIdToDataKey } from '../../src/logic/ContentDeliveryManager'
27
- import { createMockPeerDescriptor, createNetworkNodeWithSimulator } from '../utils/utils'
28
22
  import { DiscoveryLayerNode } from '../../src/logic/DiscoveryLayerNode'
29
- import { ContentDeliveryLayerNode } from '../../src/logic/ContentDeliveryLayerNode'
23
+ import { NetworkNode } from '../../src/NetworkNode'
24
+ import { ContentType, EncryptionType, SignatureType } from '../../src/proto/packages/trackerless-network/protos/NetworkRpc'
25
+ import { createMockPeerDescriptor, createNetworkNodeWithSimulator } from '../utils/utils'
30
26
 
31
27
  const numNodes = 10000
32
28
 
@@ -86,25 +82,28 @@ const measureJoiningTime = async () => {
86
82
  console.log(stream)
87
83
  publishInterval = setInterval(() => {
88
84
  i += 1
89
- const streamMessage = new StreamMessage({
90
- messageId: new MessageID(
91
- StreamPartIDUtils.getStreamID(stream),
92
- 0,
93
- i,
94
- Math.floor(Math.random() * 20000),
95
- '2222' as any,
96
- 'msgChainId'
97
- ),
98
- content: utf8ToBinary(JSON.stringify({
99
- hello: 'world'
100
- })),
101
- messageType: StreamMessageType.MESSAGE,
102
- contentType: ContentType.JSON,
103
- encryptionType: EncryptionType.NONE,
85
+ const streamMessage = {
86
+ messageId: {
87
+ streamId: StreamPartIDUtils.getStreamID(stream),
88
+ streamPartition: 0,
89
+ timestamp: i,
90
+ sequenceNumber: Math.floor(Math.random() * 20000),
91
+ publisherId: hexToBinary('0x2222'),
92
+ messageChainId: 'msgChainId'
93
+ },
94
+ body: {
95
+ oneofKind: 'contentMessage' as const,
96
+ contentMessage: {
97
+ content: utf8ToBinary(JSON.stringify({
98
+ hello: 'world'
99
+ })),
100
+ contentType: ContentType.JSON,
101
+ encryptionType: EncryptionType.NONE,
102
+ }
103
+ },
104
104
  signature: hexToBinary('0x1234'),
105
105
  signatureType: SignatureType.SECP256K1,
106
-
107
- })
106
+ }
108
107
  streamParts.get(stream)!.broadcast(streamMessage)
109
108
  }, 1000)
110
109
  // get random node from network to use as entrypoint
@@ -1,12 +1,11 @@
1
1
  import { ConnectionManager, DhtNode, PeerDescriptor } from '@streamr/dht'
2
- import { ContentDeliveryLayerNode } from '../../src/logic/ContentDeliveryLayerNode'
3
- import { waitForCondition } from '@streamr/utils'
4
- import { createMockPeerDescriptor, createStreamMessage } from '../utils/utils'
5
- import { createContentDeliveryLayerNode } from '../../src/logic/createContentDeliveryLayerNode'
6
- import { StreamPartIDUtils } from '@streamr/protocol'
7
2
  import { randomEthereumAddress } from '@streamr/test-utils'
3
+ import { StreamPartIDUtils, waitForCondition } from '@streamr/utils'
4
+ import { ContentDeliveryLayerNode } from '../../src/logic/ContentDeliveryLayerNode'
8
5
  import { ControlLayerNode } from '../../src/logic/ControlLayerNode'
9
6
  import { DiscoveryLayerNode } from '../../src/logic/DiscoveryLayerNode'
7
+ import { createContentDeliveryLayerNode } from '../../src/logic/createContentDeliveryLayerNode'
8
+ import { createMockPeerDescriptor, createStreamMessage } from '../utils/utils'
10
9
 
11
10
  describe('content delivery layer node with real connections', () => {
12
11
 
@@ -1,16 +1,7 @@
1
- import {
2
- ContentType,
3
- EncryptionType,
4
- MessageID,
5
- MessageRef,
6
- SignatureType,
7
- StreamMessage,
8
- StreamMessageType,
9
- StreamPartIDUtils
10
- } from '@streamr/protocol'
11
1
  import { randomEthereumAddress } from '@streamr/test-utils'
12
- import { hexToBinary, utf8ToBinary, waitForCondition } from '@streamr/utils'
2
+ import { StreamPartIDUtils, hexToBinary, utf8ToBinary, waitForCondition } from '@streamr/utils'
13
3
  import { NetworkNode, createNetworkNode } from '../../src/NetworkNode'
4
+ import { ContentType, EncryptionType, SignatureType, StreamMessage } from '../../src/proto/packages/trackerless-network/protos/NetworkRpc'
14
5
  import { createMockPeerDescriptor } from '../utils/utils'
15
6
 
16
7
  const STREAM_PART_ID = StreamPartIDUtils.parse('stream#0')
@@ -47,25 +38,32 @@ describe('inspect', () => {
47
38
 
48
39
  let inspectorNode: NetworkNode
49
40
 
50
- const message = new StreamMessage({
51
- messageId: new MessageID(
52
- StreamPartIDUtils.getStreamID(STREAM_PART_ID),
53
- StreamPartIDUtils.getStreamPartition(STREAM_PART_ID),
54
- 666,
55
- 0,
56
- randomEthereumAddress(),
57
- 'msgChainId'
58
- ),
59
- prevMsgRef: new MessageRef(665, 0),
60
- content: utf8ToBinary(JSON.stringify({
61
- hello: 'world'
62
- })),
63
- messageType: StreamMessageType.MESSAGE,
64
- contentType: ContentType.JSON,
65
- encryptionType: EncryptionType.NONE,
41
+ const message: StreamMessage = {
42
+ messageId: {
43
+ streamId: StreamPartIDUtils.getStreamID(STREAM_PART_ID),
44
+ streamPartition: StreamPartIDUtils.getStreamPartition(STREAM_PART_ID),
45
+ timestamp: 666,
46
+ sequenceNumber: 0,
47
+ publisherId: hexToBinary(randomEthereumAddress()),
48
+ messageChainId: 'msgChainId'
49
+ },
50
+ previousMessageRef: {
51
+ timestamp: 665,
52
+ sequenceNumber: 0
53
+ },
54
+ body: {
55
+ oneofKind: 'contentMessage',
56
+ contentMessage: {
57
+ content: utf8ToBinary(JSON.stringify({
58
+ hello: 'world'
59
+ })),
60
+ contentType: ContentType.JSON,
61
+ encryptionType: EncryptionType.NONE
62
+ }
63
+ },
66
64
  signatureType: SignatureType.SECP256K1,
67
65
  signature: hexToBinary('0x1234'),
68
- })
66
+ }
69
67
 
70
68
  beforeEach(async () => {
71
69
  publisherNode = createNetworkNode({
@@ -1,42 +1,44 @@
1
+ import { randomEthereumAddress } from '@streamr/test-utils'
2
+ import { StreamPartID, StreamPartIDUtils, hexToBinary, utf8ToBinary, waitForEvent3 } from '@streamr/utils'
3
+ import { NetworkNode, createNetworkNode } from '../../src/NetworkNode'
1
4
  import {
2
5
  ContentType,
3
6
  EncryptionType,
4
- MessageID,
5
- MessageRef,
7
+ ProxyDirection,
6
8
  SignatureType,
7
- StreamMessage,
8
- StreamMessageType,
9
- StreamPartID,
10
- StreamPartIDUtils
11
- } from '@streamr/protocol'
12
- import { randomEthereumAddress } from '@streamr/test-utils'
13
- import { hexToBinary, utf8ToBinary, waitForEvent3 } from '@streamr/utils'
14
- import { NetworkNode, createNetworkNode } from '../../src/NetworkNode'
15
- import { StreamMessage as InternalStreamMessage, ProxyDirection } from '../../src/proto/packages/trackerless-network/protos/NetworkRpc'
9
+ StreamMessage
10
+ } from '../../src/proto/packages/trackerless-network/protos/NetworkRpc'
16
11
  import { createMockPeerDescriptor } from '../utils/utils'
17
12
 
18
13
  const PROXIED_NODE_USER_ID = randomEthereumAddress()
19
14
 
20
15
  const createMessage = (streamPartId: StreamPartID): StreamMessage => {
21
- return new StreamMessage({
22
- messageId: new MessageID(
23
- StreamPartIDUtils.getStreamID(streamPartId),
24
- StreamPartIDUtils.getStreamPartition(streamPartId),
25
- 666,
26
- 0,
27
- randomEthereumAddress(),
28
- 'msgChainId'
29
- ),
30
- prevMsgRef: new MessageRef(665, 0),
31
- content: utf8ToBinary(JSON.stringify({
32
- hello: 'world'
33
- })),
34
- messageType: StreamMessageType.MESSAGE,
35
- contentType: ContentType.JSON,
36
- encryptionType: EncryptionType.NONE,
16
+ return {
17
+ messageId: {
18
+ streamId: StreamPartIDUtils.getStreamID(streamPartId),
19
+ streamPartition: StreamPartIDUtils.getStreamPartition(streamPartId),
20
+ timestamp: 666,
21
+ sequenceNumber: 0,
22
+ publisherId: hexToBinary(randomEthereumAddress()),
23
+ messageChainId: 'msgChainId'
24
+ },
25
+ previousMessageRef: {
26
+ timestamp: 665,
27
+ sequenceNumber: 0
28
+ },
29
+ body: {
30
+ oneofKind: 'contentMessage',
31
+ contentMessage: {
32
+ content: utf8ToBinary(JSON.stringify({
33
+ hello: 'world'
34
+ })),
35
+ contentType: ContentType.JSON,
36
+ encryptionType: EncryptionType.NONE,
37
+ }
38
+ },
37
39
  signatureType: SignatureType.SECP256K1,
38
40
  signature: hexToBinary('0x1234'),
39
- })
41
+ }
40
42
  }
41
43
 
42
44
  describe('proxy and full node', () => {
@@ -111,13 +113,13 @@ describe('proxy and full node', () => {
111
113
 
112
114
  await Promise.all([
113
115
  waitForEvent3(proxyNode.stack.getContentDeliveryManager() as any, 'newMessage', 5000,
114
- (streamMessage: InternalStreamMessage) => streamMessage.messageId!.streamId === StreamPartIDUtils.getStreamID(regularStreamPart1)),
116
+ (streamMessage: StreamMessage) => streamMessage.messageId!.streamId === StreamPartIDUtils.getStreamID(regularStreamPart1)),
115
117
  waitForEvent3(proxyNode.stack.getContentDeliveryManager() as any, 'newMessage', 5000,
116
- (streamMessage: InternalStreamMessage) => streamMessage.messageId!.streamId === StreamPartIDUtils.getStreamID(regularStreamPart2)),
118
+ (streamMessage: StreamMessage) => streamMessage.messageId!.streamId === StreamPartIDUtils.getStreamID(regularStreamPart2)),
117
119
  waitForEvent3(proxyNode.stack.getContentDeliveryManager() as any, 'newMessage', 5000,
118
- (streamMessage: InternalStreamMessage) => streamMessage.messageId!.streamId === StreamPartIDUtils.getStreamID(regularStreamPart3)),
120
+ (streamMessage: StreamMessage) => streamMessage.messageId!.streamId === StreamPartIDUtils.getStreamID(regularStreamPart3)),
119
121
  waitForEvent3(proxyNode.stack.getContentDeliveryManager() as any, 'newMessage', 5000,
120
- (streamMessage: InternalStreamMessage) => streamMessage.messageId!.streamId === StreamPartIDUtils.getStreamID(regularStreamPart4)),
122
+ (streamMessage: StreamMessage) => streamMessage.messageId!.streamId === StreamPartIDUtils.getStreamID(regularStreamPart4)),
121
123
  proxiedNode.broadcast(createMessage(regularStreamPart1)),
122
124
  proxiedNode.broadcast(createMessage(regularStreamPart2)),
123
125
  proxiedNode.broadcast(createMessage(regularStreamPart3)),