@streamr/dht 100.0.0-testnet-two.1 → 100.0.0-testnet-two.2

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 (170) hide show
  1. package/dist/package.json +5 -5
  2. package/dist/src/connection/ConnectionLockHandler.d.ts +11 -11
  3. package/dist/src/connection/ConnectionLockHandler.js.map +1 -1
  4. package/dist/src/connection/ConnectionLockRpcLocal.d.ts +3 -3
  5. package/dist/src/connection/ConnectionManager.js +3 -3
  6. package/dist/src/connection/ConnectionManager.js.map +1 -1
  7. package/dist/src/connection/ManagedConnection.d.ts +2 -2
  8. package/dist/src/connection/simulator/Simulator.js.map +1 -1
  9. package/dist/src/connection/simulator/SimulatorConnector.js.map +1 -1
  10. package/dist/src/connection/webrtc/WebrtcConnector.js +1 -1
  11. package/dist/src/connection/webrtc/WebrtcConnector.js.map +1 -1
  12. package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.d.ts +2 -2
  13. package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js +1 -1
  14. package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js.map +1 -1
  15. package/dist/src/connection/websocket/WebsocketConnector.js +2 -2
  16. package/dist/src/connection/websocket/WebsocketConnector.js.map +1 -1
  17. package/dist/src/dht/DhtNode.d.ts +9 -8
  18. package/dist/src/dht/DhtNode.js +21 -16
  19. package/dist/src/dht/DhtNode.js.map +1 -1
  20. package/dist/src/dht/DhtNodeRpcLocal.d.ts +2 -1
  21. package/dist/src/dht/DhtNodeRpcLocal.js +2 -1
  22. package/dist/src/dht/DhtNodeRpcLocal.js.map +1 -1
  23. package/dist/src/dht/DhtNodeRpcRemote.d.ts +6 -5
  24. package/dist/src/dht/DhtNodeRpcRemote.js +9 -7
  25. package/dist/src/dht/DhtNodeRpcRemote.js.map +1 -1
  26. package/dist/src/dht/ExternalApiRpcLocal.d.ts +3 -3
  27. package/dist/src/dht/ExternalApiRpcLocal.js +3 -2
  28. package/dist/src/dht/ExternalApiRpcLocal.js.map +1 -1
  29. package/dist/src/dht/ExternalApiRpcRemote.d.ts +3 -2
  30. package/dist/src/dht/ExternalApiRpcRemote.js +3 -2
  31. package/dist/src/dht/ExternalApiRpcRemote.js.map +1 -1
  32. package/dist/src/dht/PeerManager.d.ts +9 -9
  33. package/dist/src/dht/PeerManager.js +12 -12
  34. package/dist/src/dht/PeerManager.js.map +1 -1
  35. package/dist/src/dht/contact/Contact.d.ts +2 -2
  36. package/dist/src/dht/contact/ContactList.d.ts +7 -7
  37. package/dist/src/dht/contact/ContactList.js.map +1 -1
  38. package/dist/src/dht/contact/RandomContactList.d.ts +4 -4
  39. package/dist/src/dht/contact/RandomContactList.js +2 -3
  40. package/dist/src/dht/contact/RandomContactList.js.map +1 -1
  41. package/dist/src/dht/contact/RpcRemote.d.ts +1 -4
  42. package/dist/src/dht/contact/RpcRemote.js +1 -5
  43. package/dist/src/dht/contact/RpcRemote.js.map +1 -1
  44. package/dist/src/dht/contact/SortedContactList.d.ts +13 -13
  45. package/dist/src/dht/contact/SortedContactList.js +5 -5
  46. package/dist/src/dht/contact/SortedContactList.js.map +1 -1
  47. package/dist/src/dht/discovery/DiscoverySession.d.ts +3 -2
  48. package/dist/src/dht/discovery/DiscoverySession.js +9 -9
  49. package/dist/src/dht/discovery/DiscoverySession.js.map +1 -1
  50. package/dist/src/dht/discovery/PeerDiscovery.d.ts +3 -1
  51. package/dist/src/dht/discovery/PeerDiscovery.js +16 -9
  52. package/dist/src/dht/discovery/PeerDiscovery.js.map +1 -1
  53. package/dist/src/dht/recursive-operation/RecursiveOperationManager.d.ts +3 -3
  54. package/dist/src/dht/recursive-operation/RecursiveOperationManager.js +12 -11
  55. package/dist/src/dht/recursive-operation/RecursiveOperationManager.js.map +1 -1
  56. package/dist/src/dht/recursive-operation/RecursiveOperationSession.d.ts +2 -1
  57. package/dist/src/dht/recursive-operation/RecursiveOperationSession.js +6 -6
  58. package/dist/src/dht/recursive-operation/RecursiveOperationSession.js.map +1 -1
  59. package/dist/src/dht/routing/Router.d.ts +2 -2
  60. package/dist/src/dht/routing/Router.js +2 -2
  61. package/dist/src/dht/routing/Router.js.map +1 -1
  62. package/dist/src/dht/routing/RouterRpcLocal.js +3 -3
  63. package/dist/src/dht/routing/RouterRpcLocal.js.map +1 -1
  64. package/dist/src/dht/routing/RoutingSession.d.ts +3 -3
  65. package/dist/src/dht/routing/RoutingSession.js +4 -4
  66. package/dist/src/dht/routing/RoutingSession.js.map +1 -1
  67. package/dist/src/dht/store/LocalDataStore.d.ts +6 -8
  68. package/dist/src/dht/store/LocalDataStore.js +18 -24
  69. package/dist/src/dht/store/LocalDataStore.js.map +1 -1
  70. package/dist/src/dht/store/StoreManager.d.ts +3 -3
  71. package/dist/src/dht/store/StoreManager.js +20 -21
  72. package/dist/src/dht/store/StoreManager.js.map +1 -1
  73. package/dist/src/dht/store/StoreRpcLocal.d.ts +2 -1
  74. package/dist/src/dht/store/StoreRpcLocal.js +10 -8
  75. package/dist/src/dht/store/StoreRpcLocal.js.map +1 -1
  76. package/dist/src/exports.d.ts +2 -0
  77. package/dist/src/exports.js +6 -1
  78. package/dist/src/exports.js.map +1 -1
  79. package/dist/src/helpers/AddressTools.js +2 -0
  80. package/dist/src/helpers/AddressTools.js.map +1 -1
  81. package/dist/src/helpers/PeerID.d.ts +2 -2
  82. package/dist/src/helpers/PeerID.js +3 -3
  83. package/dist/src/helpers/PeerID.js.map +1 -1
  84. package/dist/src/helpers/peerIdFromPeerDescriptor.d.ts +2 -2
  85. package/dist/src/helpers/peerIdFromPeerDescriptor.js +2 -1
  86. package/dist/src/helpers/peerIdFromPeerDescriptor.js.map +1 -1
  87. package/dist/src/identifiers.d.ts +6 -0
  88. package/dist/src/identifiers.js +23 -0
  89. package/dist/src/identifiers.js.map +1 -0
  90. package/package.json +5 -5
  91. package/src/connection/ConnectionLockHandler.ts +15 -15
  92. package/src/connection/ConnectionLockRpcLocal.ts +3 -3
  93. package/src/connection/ConnectionManager.ts +4 -7
  94. package/src/connection/ManagedConnection.ts +2 -2
  95. package/src/connection/simulator/Simulator.ts +2 -2
  96. package/src/connection/simulator/SimulatorConnector.ts +2 -2
  97. package/src/connection/webrtc/BrowserWebrtcConnection.ts +0 -4
  98. package/src/connection/webrtc/WebrtcConnector.ts +2 -3
  99. package/src/connection/webrtc/WebrtcConnectorRpcLocal.ts +2 -3
  100. package/src/connection/websocket/WebsocketConnector.ts +5 -6
  101. package/src/dht/DhtNode.ts +31 -29
  102. package/src/dht/DhtNodeRpcLocal.ts +3 -2
  103. package/src/dht/DhtNodeRpcRemote.ts +14 -12
  104. package/src/dht/ExternalApiRpcLocal.ts +15 -6
  105. package/src/dht/ExternalApiRpcRemote.ts +5 -4
  106. package/src/dht/PeerManager.ts +20 -20
  107. package/src/dht/contact/Contact.ts +2 -2
  108. package/src/dht/contact/ContactList.ts +7 -7
  109. package/src/dht/contact/RandomContactList.ts +6 -6
  110. package/src/dht/contact/RpcRemote.ts +0 -8
  111. package/src/dht/contact/SortedContactList.ts +22 -22
  112. package/src/dht/discovery/DiscoverySession.ts +16 -14
  113. package/src/dht/discovery/PeerDiscovery.ts +32 -11
  114. package/src/dht/recursive-operation/RecursiveOperationManager.ts +14 -14
  115. package/src/dht/recursive-operation/RecursiveOperationSession.ts +11 -11
  116. package/src/dht/routing/Router.ts +5 -5
  117. package/src/dht/routing/RouterRpcLocal.ts +3 -3
  118. package/src/dht/routing/RoutingSession.ts +6 -8
  119. package/src/dht/store/LocalDataStore.ts +25 -33
  120. package/src/dht/store/StoreManager.ts +25 -29
  121. package/src/dht/store/StoreRpcLocal.ts +11 -9
  122. package/src/exports.ts +2 -0
  123. package/src/helpers/AddressTools.ts +2 -0
  124. package/src/helpers/PeerID.ts +4 -4
  125. package/src/helpers/peerIdFromPeerDescriptor.ts +4 -4
  126. package/src/identifiers.ts +20 -0
  127. package/test/RandomGraphSimulation.ts +3 -2
  128. package/test/benchmark/Find.test.ts +4 -3
  129. package/test/benchmark/KademliaCorrectness.test.ts +4 -4
  130. package/test/benchmark/SortedContactListBenchmark.test.ts +15 -14
  131. package/test/benchmark/kademlia-simulation/Contact.ts +7 -8
  132. package/test/benchmark/kademlia-simulation/KademliaSimulation.ts +2 -2
  133. package/test/benchmark/kademlia-simulation/SimulationNode.ts +10 -11
  134. package/test/data/generateGroundTruthData.ts +5 -4
  135. package/test/end-to-end/Layer0Webrtc-Layer1.test.ts +2 -2
  136. package/test/end-to-end/RecoveryFromFailedAutoCertification.test.ts +1 -1
  137. package/test/end-to-end/memory-leak.test.ts +3 -2
  138. package/test/integration/ConnectionManager.test.ts +3 -3
  139. package/test/integration/DhtJoinPeerDiscovery.test.ts +2 -1
  140. package/test/integration/DhtNodeExternalAPI.test.ts +7 -7
  141. package/test/integration/DhtNodeRpcRemote.test.ts +3 -2
  142. package/test/integration/Find.test.ts +3 -3
  143. package/test/integration/Layer1-scale.test.ts +3 -3
  144. package/test/integration/Mock-Layer1-Layer0.test.ts +6 -5
  145. package/test/integration/ReplicateData.test.ts +25 -23
  146. package/test/integration/RouteMessage.test.ts +9 -10
  147. package/test/integration/RouterRpcRemote.test.ts +1 -1
  148. package/test/integration/ScaleDownDht.test.ts +4 -4
  149. package/test/integration/SimultaneousConnections.test.ts +7 -14
  150. package/test/integration/Store.test.ts +17 -7
  151. package/test/integration/StoreAndDelete.test.ts +11 -10
  152. package/test/integration/StoreOnDhtWithTwoNodes.test.ts +7 -6
  153. package/test/integration/StoreRpcRemote.test.ts +3 -5
  154. package/test/unit/AddressTools.test.ts +4 -0
  155. package/test/unit/LocalDataStore.test.ts +37 -29
  156. package/test/unit/PeerManager.test.ts +7 -8
  157. package/test/unit/RandomContactList.test.ts +3 -3
  158. package/test/unit/RecursiveOperationManager.test.ts +2 -1
  159. package/test/unit/RecursiveOperationSession.test.ts +2 -3
  160. package/test/unit/Router.test.ts +2 -2
  161. package/test/unit/RoutingSession.test.ts +2 -2
  162. package/test/unit/SortedContactList.test.ts +6 -6
  163. package/test/unit/StoreManager.test.ts +26 -23
  164. package/test/utils/customMatchers.ts +3 -2
  165. package/test/utils/mock/mockDataEntry.ts +8 -6
  166. package/test/utils/utils.ts +4 -4
  167. package/dist/src/helpers/nodeId.d.ts +0 -6
  168. package/dist/src/helpers/nodeId.js +0 -31
  169. package/dist/src/helpers/nodeId.js.map +0 -1
  170. package/src/helpers/nodeId.ts +0 -28
@@ -25,7 +25,6 @@ import { ExternalApiRpcClient, StoreRpcClient } from '../proto/packages/dht/prot
25
25
  import {
26
26
  Logger,
27
27
  MetricsContext,
28
- hexToBinary,
29
28
  merge,
30
29
  waitForCondition
31
30
  } from '@streamr/utils'
@@ -50,7 +49,7 @@ import { ServerCallContext } from '@protobuf-ts/runtime-rpc'
50
49
  import { ExternalApiRpcLocal } from './ExternalApiRpcLocal'
51
50
  import { PeerManager } from './PeerManager'
52
51
  import { ServiceID } from '../types/ServiceID'
53
- import { NodeID, getNodeIdFromBinary } from '../helpers/nodeId'
52
+ import { DhtAddress, DhtAddressRaw, getRawFromDhtAddress } from '../identifiers'
54
53
  import { StoreRpcRemote } from './store/StoreRpcRemote'
55
54
 
56
55
  export interface DhtNodeEvents {
@@ -118,11 +117,11 @@ const logger = new Logger(module)
118
117
  export type Events = TransportEvents & DhtNodeEvents
119
118
 
120
119
  export const createPeerDescriptor = (msg?: ConnectivityResponse, peerId?: string): PeerDescriptor => {
121
- let nodeId: Uint8Array
120
+ let nodeId: DhtAddressRaw
122
121
  if (msg) {
123
- nodeId = (peerId !== undefined) ? hexToBinary(peerId) : PeerID.fromIp(msg.host).value
122
+ nodeId = (peerId !== undefined) ? getRawFromDhtAddress(peerId as DhtAddress) : PeerID.fromIp(msg.host).value
124
123
  } else {
125
- nodeId = hexToBinary(peerId!)
124
+ nodeId = getRawFromDhtAddress(peerId! as DhtAddress)
126
125
  }
127
126
  const nodeType = isBrowserEnvironment() ? NodeType.BROWSER : NodeType.NODEJS
128
127
  const ret: PeerDescriptor = { nodeId, type: nodeType }
@@ -276,14 +275,13 @@ export class DhtNode extends EventEmitter<Events> implements ITransport {
276
275
  highestTtl: this.config.storeHighestTtl,
277
276
  redundancyFactor: this.config.storageRedundancyFactor,
278
277
  localDataStore: this.localDataStore,
279
- getClosestNeighborsTo: (id: Uint8Array, n?: number) => {
280
- return this.peerManager!.getClosestNeighborsTo(getNodeIdFromBinary(id), n).map((n) => n.getPeerDescriptor())
278
+ getClosestNeighborsTo: (key: DhtAddress, n?: number) => {
279
+ return this.peerManager!.getClosestNeighborsTo(key, n).map((n) => n.getPeerDescriptor())
281
280
  },
282
281
  createRpcRemote: (contact: PeerDescriptor) => {
283
282
  return new StoreRpcRemote(
284
283
  this.localPeerDescriptor!,
285
284
  contact,
286
- this.config.serviceId,
287
285
  this.rpcCommunicator!,
288
286
  StoreRpcClient,
289
287
  this.config.rpcRequestTimeout
@@ -350,8 +348,8 @@ export class DhtNode extends EventEmitter<Events> implements ITransport {
350
348
  }
351
349
  const dhtNodeRpcLocal = new DhtNodeRpcLocal({
352
350
  peerDiscoveryQueryBatchSize: this.config.peerDiscoveryQueryBatchSize,
353
- getClosestPeersTo: (kademliaId: Uint8Array, limit: number) => {
354
- return this.peerManager!.getClosestNeighborsTo(getNodeIdFromBinary(kademliaId), limit)
351
+ getClosestPeersTo: (nodeId: DhtAddress, limit: number) => {
352
+ return this.peerManager!.getClosestNeighborsTo(nodeId, limit)
355
353
  .map((dhtPeer: DhtNodeRpcRemote) => dhtPeer.getPeerDescriptor())
356
354
  },
357
355
  addNewContact: (contact: PeerDescriptor) => this.peerManager!.handleNewPeers([contact]),
@@ -364,10 +362,10 @@ export class DhtNode extends EventEmitter<Events> implements ITransport {
364
362
  this.rpcCommunicator!.registerRpcNotification(LeaveNotice, 'leaveNotice',
365
363
  (_req: LeaveNotice, context) => dhtNodeRpcLocal.leaveNotice(context))
366
364
  const externalApiRpcLocal = new ExternalApiRpcLocal({
367
- executeRecursiveOperation: (key: Uint8Array, operation: RecursiveOperation, excludedPeer: PeerDescriptor) => {
365
+ executeRecursiveOperation: (key: DhtAddress, operation: RecursiveOperation, excludedPeer: PeerDescriptor) => {
368
366
  return this.executeRecursiveOperation(key, operation, excludedPeer)
369
367
  },
370
- storeDataToDht: (key: Uint8Array, data: Any, creator?: NodeID) => this.storeDataToDht(key, data, creator)
368
+ storeDataToDht: (key: DhtAddress, data: Any, creator?: DhtAddress) => this.storeDataToDht(key, data, creator)
371
369
  })
372
370
  this.rpcCommunicator!.registerRpcMethod(
373
371
  ExternalFindDataRequest,
@@ -413,7 +411,7 @@ export class DhtNode extends EventEmitter<Events> implements ITransport {
413
411
  )
414
412
  }
415
413
 
416
- public getNodeId(): NodeID {
414
+ public getNodeId(): DhtAddress {
417
415
  return getNodeIdFromPeerDescriptor(this.localPeerDescriptor!)
418
416
  }
419
417
 
@@ -432,66 +430,70 @@ export class DhtNode extends EventEmitter<Events> implements ITransport {
432
430
  if (!this.started || this.abortController.signal.aborted) {
433
431
  return
434
432
  }
435
- const reachableThrough = this.peerDiscovery!.isJoinOngoing() ? this.config.entryPoints ?? [] : []
433
+ const reachableThrough = this.peerDiscovery!.isJoinOngoing() ? this.getConnectedEntryPoints() : []
436
434
  this.router!.send(msg, reachableThrough)
437
435
  }
438
436
 
437
+ private getConnectedEntryPoints(): PeerDescriptor[] {
438
+ return this.config.entryPoints !== undefined ? this.config.entryPoints.filter((entryPoint) =>
439
+ this.peerManager!.connections.has(getNodeIdFromPeerDescriptor(entryPoint))
440
+ ) : []
441
+ }
442
+
439
443
  public async joinDht(entryPointDescriptors: PeerDescriptor[], doAdditionalRandomPeerDiscovery?: boolean, retry?: boolean): Promise<void> {
440
444
  if (!this.started) {
441
445
  throw new Error('Cannot join DHT before calling start() on DhtNode')
442
446
  }
443
- await Promise.all(entryPointDescriptors.map((entryPoint) =>
444
- this.peerDiscovery!.joinDht(entryPoint, doAdditionalRandomPeerDiscovery, retry)
445
- ))
447
+ await this.peerDiscovery!.joinDht(entryPointDescriptors, doAdditionalRandomPeerDiscovery, retry)
446
448
  }
447
449
 
448
450
  // TODO make this private and unify the public API of find/fetch/store/delete methods
449
451
  // (we already have storeDataToDht etc. here)
450
452
  public async executeRecursiveOperation(
451
- key: Uint8Array,
453
+ key: DhtAddress,
452
454
  operation: RecursiveOperation,
453
455
  excludedPeer?: PeerDescriptor
454
456
  ): Promise<RecursiveOperationResult> {
455
457
  return this.recursiveOperationManager!.execute(key, operation, excludedPeer)
456
458
  }
457
459
 
458
- public async storeDataToDht(key: Uint8Array, data: Any, creator?: NodeID): Promise<PeerDescriptor[]> {
459
- if (this.peerDiscovery!.isJoinOngoing() && this.config.entryPoints && this.config.entryPoints.length > 0) {
460
- return this.storeDataViaPeer(key, data, sample(this.config.entryPoints)!)
460
+ public async storeDataToDht(key: DhtAddress, data: Any, creator?: DhtAddress): Promise<PeerDescriptor[]> {
461
+ const connectedEntryPoints = this.getConnectedEntryPoints()
462
+ if (this.peerDiscovery!.isJoinOngoing() && connectedEntryPoints.length > 0) {
463
+ return this.storeDataViaPeer(key, data, sample(connectedEntryPoints)!)
461
464
  }
462
465
  return this.storeManager!.storeDataToDht(key, data, creator ?? getNodeIdFromPeerDescriptor(this.localPeerDescriptor!))
463
466
  }
464
467
 
465
- public async storeDataViaPeer(key: Uint8Array, data: Any, peer: PeerDescriptor): Promise<PeerDescriptor[]> {
468
+ public async storeDataViaPeer(key: DhtAddress, data: Any, peer: PeerDescriptor): Promise<PeerDescriptor[]> {
466
469
  const rpcRemote = new ExternalApiRpcRemote(
467
470
  this.localPeerDescriptor!,
468
471
  peer,
469
- this.config.serviceId,
470
472
  this.rpcCommunicator!,
471
473
  ExternalApiRpcClient
472
474
  )
473
475
  return await rpcRemote.storeData(key, data)
474
476
  }
475
477
 
476
- public async getDataFromDht(key: Uint8Array): Promise<DataEntry[]> {
477
- if (this.peerDiscovery!.isJoinOngoing() && this.config.entryPoints && this.config.entryPoints.length > 0) {
478
- return this.findDataViaPeer(key, sample(this.config.entryPoints)!)
478
+ public async getDataFromDht(key: DhtAddress): Promise<DataEntry[]> {
479
+ const connectedEntryPoints = this.getConnectedEntryPoints()
480
+ if (this.peerDiscovery!.isJoinOngoing() && connectedEntryPoints.length > 0) {
481
+ return this.findDataViaPeer(key, sample(connectedEntryPoints)!)
479
482
  }
480
483
  const result = await this.recursiveOperationManager!.execute(key, RecursiveOperation.FETCH_DATA)
481
484
  return result.dataEntries ?? [] // TODO is this fallback needed?
482
485
  }
483
486
 
484
- public async deleteDataFromDht(key: Uint8Array, waitForCompletion: boolean): Promise<void> {
487
+ public async deleteDataFromDht(key: DhtAddress, waitForCompletion: boolean): Promise<void> {
485
488
  if (!this.abortController.signal.aborted) {
486
489
  await this.recursiveOperationManager!.execute(key, RecursiveOperation.DELETE_DATA, undefined, waitForCompletion)
487
490
  }
488
491
  }
489
492
 
490
- public async findDataViaPeer(key: Uint8Array, peer: PeerDescriptor): Promise<DataEntry[]> {
493
+ public async findDataViaPeer(key: DhtAddress, peer: PeerDescriptor): Promise<DataEntry[]> {
491
494
  const rpcRemote = new ExternalApiRpcRemote(
492
495
  this.localPeerDescriptor!,
493
496
  peer,
494
- this.config.serviceId,
495
497
  this.rpcCommunicator!,
496
498
  ExternalApiRpcClient
497
499
  )
@@ -11,10 +11,11 @@ import {
11
11
  } from '../proto/packages/dht/protos/DhtRpc'
12
12
  import { IDhtNodeRpc } from '../proto/packages/dht/protos/DhtRpc.server'
13
13
  import { DhtCallContext } from '../rpc-protocol/DhtCallContext'
14
+ import { DhtAddress, getDhtAddressFromRaw } from '../identifiers'
14
15
 
15
16
  interface DhtNodeRpcLocalConfig {
16
17
  peerDiscoveryQueryBatchSize: number
17
- getClosestPeersTo: (nodeId: Uint8Array, limit: number) => PeerDescriptor[]
18
+ getClosestPeersTo: (nodeId: DhtAddress, limit: number) => PeerDescriptor[]
18
19
  addNewContact: (contact: PeerDescriptor) => void
19
20
  removeContact: (contact: PeerDescriptor) => void
20
21
  }
@@ -32,7 +33,7 @@ export class DhtNodeRpcLocal implements IDhtNodeRpc {
32
33
  async getClosestPeers(request: ClosestPeersRequest, context: ServerCallContext): Promise<ClosestPeersResponse> {
33
34
  this.config.addNewContact((context as DhtCallContext).incomingSourceDescriptor!)
34
35
  const response = {
35
- peers: this.config.getClosestPeersTo(request.nodeId, this.config.peerDiscoveryQueryBatchSize),
36
+ peers: this.config.getClosestPeersTo(getDhtAddressFromRaw(request.nodeId), this.config.peerDiscoveryQueryBatchSize),
36
37
  requestId: request.requestId
37
38
  }
38
39
  return response
@@ -1,7 +1,7 @@
1
1
  import { RpcCommunicator } from '@streamr/proto-rpc'
2
2
  import { Logger } from '@streamr/utils'
3
3
  import { v4 } from 'uuid'
4
- import { NodeID } from '../helpers/nodeId'
4
+ import { DhtAddress, DhtAddressRaw, getRawFromDhtAddress } from '../identifiers'
5
5
  import { getNodeIdFromPeerDescriptor } from '../helpers/peerIdFromPeerDescriptor'
6
6
  import {
7
7
  ClosestPeersRequest,
@@ -16,7 +16,7 @@ const logger = new Logger(module)
16
16
 
17
17
  // Fields required by objects stored in the k-bucket library
18
18
  export interface KBucketContact {
19
- id: Uint8Array
19
+ id: DhtAddressRaw
20
20
  vectorClock: number
21
21
  }
22
22
 
@@ -24,7 +24,8 @@ export class DhtNodeRpcRemote extends RpcRemote<DhtNodeRpcClient> implements KBu
24
24
 
25
25
  private static counter = 0
26
26
  public vectorClock: number
27
- public readonly id: Uint8Array
27
+ public readonly id: DhtAddressRaw
28
+ private readonly serviceId: ServiceID
28
29
 
29
30
  constructor(
30
31
  localPeerDescriptor: PeerDescriptor,
@@ -33,28 +34,29 @@ export class DhtNodeRpcRemote extends RpcRemote<DhtNodeRpcClient> implements KBu
33
34
  rpcCommunicator: RpcCommunicator,
34
35
  rpcRequestTimeout?: number
35
36
  ) {
36
- super(localPeerDescriptor, peerDescriptor, serviceId, rpcCommunicator, DhtNodeRpcClient, rpcRequestTimeout)
37
+ super(localPeerDescriptor, peerDescriptor, rpcCommunicator, DhtNodeRpcClient, rpcRequestTimeout)
37
38
  this.id = this.getPeerDescriptor().nodeId
38
39
  this.vectorClock = DhtNodeRpcRemote.counter++
40
+ this.serviceId = serviceId
39
41
  }
40
42
 
41
- async getClosestPeers(nodeId: Uint8Array): Promise<PeerDescriptor[]> {
42
- logger.trace(`Requesting getClosestPeers on ${this.getServiceId()} from ${getNodeIdFromPeerDescriptor(this.getPeerDescriptor())}`)
43
+ async getClosestPeers(nodeId: DhtAddress): Promise<PeerDescriptor[]> {
44
+ logger.trace(`Requesting getClosestPeers on ${this.serviceId} from ${getNodeIdFromPeerDescriptor(this.getPeerDescriptor())}`)
43
45
  const request: ClosestPeersRequest = {
44
- nodeId,
46
+ nodeId: getRawFromDhtAddress(nodeId),
45
47
  requestId: v4()
46
48
  }
47
49
  try {
48
50
  const peers = await this.getClient().getClosestPeers(request, this.formDhtRpcOptions())
49
51
  return peers.peers
50
52
  } catch (err) {
51
- logger.trace(`getClosestPeers error ${this.getServiceId()}`, { err })
53
+ logger.trace(`getClosestPeers error ${this.serviceId}`, { err })
52
54
  throw err
53
55
  }
54
56
  }
55
57
 
56
58
  async ping(): Promise<boolean> {
57
- logger.trace(`Requesting ping on ${this.getServiceId()} from ${getNodeIdFromPeerDescriptor(this.getPeerDescriptor())}`)
59
+ logger.trace(`Requesting ping on ${this.serviceId} from ${getNodeIdFromPeerDescriptor(this.getPeerDescriptor())}`)
58
60
  const request: PingRequest = {
59
61
  requestId: v4()
60
62
  }
@@ -65,13 +67,13 @@ export class DhtNodeRpcRemote extends RpcRemote<DhtNodeRpcClient> implements KBu
65
67
  return true
66
68
  }
67
69
  } catch (err) {
68
- logger.trace(`ping failed on ${this.getServiceId()} to ${getNodeIdFromPeerDescriptor(this.getPeerDescriptor())}: ${err}`)
70
+ logger.trace(`ping failed on ${this.serviceId} to ${getNodeIdFromPeerDescriptor(this.getPeerDescriptor())}: ${err}`)
69
71
  }
70
72
  return false
71
73
  }
72
74
 
73
75
  leaveNotice(): void {
74
- logger.trace(`Sending leaveNotice on ${this.getServiceId()} from ${getNodeIdFromPeerDescriptor(this.getPeerDescriptor())}`)
76
+ logger.trace(`Sending leaveNotice on ${this.serviceId} from ${getNodeIdFromPeerDescriptor(this.getPeerDescriptor())}`)
75
77
  const options = this.formDhtRpcOptions({
76
78
  notification: true
77
79
  })
@@ -80,7 +82,7 @@ export class DhtNodeRpcRemote extends RpcRemote<DhtNodeRpcClient> implements KBu
80
82
  })
81
83
  }
82
84
 
83
- getNodeId(): NodeID {
85
+ getNodeId(): DhtAddress {
84
86
  return getNodeIdFromPeerDescriptor(this.getPeerDescriptor())
85
87
  }
86
88
  }
@@ -11,19 +11,20 @@ import { ServerCallContext } from '@protobuf-ts/runtime-rpc'
11
11
  import { DhtCallContext } from '../rpc-protocol/DhtCallContext'
12
12
  import { RecursiveOperationResult } from './recursive-operation/RecursiveOperationManager'
13
13
  import { Any } from '../proto/google/protobuf/any'
14
- import { NodeID } from '../helpers/nodeId'
14
+ import { DhtAddress } from '../identifiers'
15
15
  import { getNodeIdFromPeerDescriptor } from '../helpers/peerIdFromPeerDescriptor'
16
+ import { getDhtAddressFromRaw } from '../identifiers'
16
17
 
17
18
  interface ExternalApiRpcLocalConfig {
18
19
  executeRecursiveOperation: (
19
- targetId: Uint8Array,
20
+ targetId: DhtAddress,
20
21
  operation: RecursiveOperation,
21
22
  excludedPeer: PeerDescriptor
22
23
  ) => Promise<RecursiveOperationResult>
23
24
  storeDataToDht: (
24
- key: Uint8Array,
25
+ key: DhtAddress,
25
26
  data: Any,
26
- creator: NodeID
27
+ creator: DhtAddress
27
28
  ) => Promise<PeerDescriptor[]>
28
29
  }
29
30
 
@@ -37,13 +38,21 @@ export class ExternalApiRpcLocal implements IExternalApiRpc {
37
38
 
38
39
  async externalFindData(findDataRequest: ExternalFindDataRequest, context: ServerCallContext): Promise<ExternalFindDataResponse> {
39
40
  const senderPeerDescriptor = (context as DhtCallContext).incomingSourceDescriptor!
40
- const result = await this.config.executeRecursiveOperation(findDataRequest.key, RecursiveOperation.FETCH_DATA, senderPeerDescriptor)
41
+ const result = await this.config.executeRecursiveOperation(
42
+ getDhtAddressFromRaw(findDataRequest.key),
43
+ RecursiveOperation.FETCH_DATA,
44
+ senderPeerDescriptor
45
+ )
41
46
  return ExternalFindDataResponse.create({ entries: result.dataEntries ?? [] })
42
47
  }
43
48
 
44
49
  async externalStoreData(request: ExternalStoreDataRequest, context: ServerCallContext): Promise<ExternalStoreDataResponse> {
45
50
  const senderPeerDescriptor = (context as DhtCallContext).incomingSourceDescriptor!
46
- const result = await this.config.storeDataToDht(request.key, request.data!, getNodeIdFromPeerDescriptor(senderPeerDescriptor))
51
+ const result = await this.config.storeDataToDht(
52
+ getDhtAddressFromRaw(request.key),
53
+ request.data!,
54
+ getNodeIdFromPeerDescriptor(senderPeerDescriptor)
55
+ )
47
56
  return ExternalStoreDataResponse.create({
48
57
  storers: result
49
58
  })
@@ -1,3 +1,4 @@
1
+ import { DhtAddress, getRawFromDhtAddress } from '../identifiers'
1
2
  import { Any } from '../proto/google/protobuf/any'
2
3
  import { DataEntry, ExternalFindDataRequest, ExternalStoreDataRequest, PeerDescriptor } from '../proto/packages/dht/protos/DhtRpc'
3
4
  import { ExternalApiRpcClient } from '../proto/packages/dht/protos/DhtRpc.client'
@@ -5,9 +6,9 @@ import { RpcRemote } from './contact/RpcRemote'
5
6
 
6
7
  export class ExternalApiRpcRemote extends RpcRemote<ExternalApiRpcClient> {
7
8
 
8
- async externalFindData(key: Uint8Array): Promise<DataEntry[]> {
9
+ async externalFindData(key: DhtAddress): Promise<DataEntry[]> {
9
10
  const request: ExternalFindDataRequest = {
10
- key
11
+ key: getRawFromDhtAddress(key)
11
12
  }
12
13
  const options = this.formDhtRpcOptions({
13
14
  // TODO use config option or named constant?
@@ -21,9 +22,9 @@ export class ExternalApiRpcRemote extends RpcRemote<ExternalApiRpcClient> {
21
22
  }
22
23
  }
23
24
 
24
- async storeData(key: Uint8Array, data: Any): Promise<PeerDescriptor[]> {
25
+ async storeData(key: DhtAddress, data: Any): Promise<PeerDescriptor[]> {
25
26
  const request: ExternalStoreDataRequest = {
26
- key,
27
+ key: getRawFromDhtAddress(key),
27
28
  data
28
29
  }
29
30
  const options = this.formDhtRpcOptions({
@@ -1,5 +1,5 @@
1
1
  import {
2
- Logger, hexToBinary
2
+ Logger
3
3
  } from '@streamr/utils'
4
4
  import KBucket from 'k-bucket'
5
5
  import {
@@ -13,7 +13,7 @@ import { RandomContactList } from './contact/RandomContactList'
13
13
  import { SortedContactList } from './contact/SortedContactList'
14
14
  import { ConnectionManager } from '../connection/ConnectionManager'
15
15
  import EventEmitter from 'eventemitter3'
16
- import { NodeID, areEqualNodeIds } from '../helpers/nodeId'
16
+ import { DhtAddress, DhtAddressRaw, getRawFromDhtAddress } from '../identifiers'
17
17
 
18
18
  const logger = new Logger(module)
19
19
 
@@ -21,7 +21,7 @@ interface PeerManagerConfig {
21
21
  numberOfNodesPerKBucket: number
22
22
  maxContactListSize: number
23
23
  peerDiscoveryQueryBatchSize: number
24
- localNodeId: NodeID
24
+ localNodeId: DhtAddress
25
25
  connectionManager: ConnectionManager
26
26
  isLayer0: boolean
27
27
  createDhtNodeRpcRemote: (peerDescriptor: PeerDescriptor) => DhtNodeRpcRemote
@@ -35,8 +35,8 @@ export interface PeerManagerEvents {
35
35
  kBucketEmpty: () => void
36
36
  }
37
37
 
38
- export const getDistance = (nodeId1: NodeID, nodeId2: NodeID): number => {
39
- return KBucket.distance(hexToBinary(nodeId1), hexToBinary(nodeId2))
38
+ export const getDistance = (nodeIdOrDataKeyRaw1: DhtAddressRaw, nodeIdOrDataKeyRaw2: DhtAddressRaw): number => {
39
+ return KBucket.distance(nodeIdOrDataKeyRaw1, nodeIdOrDataKeyRaw2)
40
40
  }
41
41
 
42
42
  export class PeerManager extends EventEmitter<PeerManagerEvents> {
@@ -50,7 +50,7 @@ export class PeerManager extends EventEmitter<PeerManagerEvents> {
50
50
  // The kademlia k-bucket
51
51
  private bucket: KBucket<DhtNodeRpcRemote>
52
52
  // Nodes that are connected to this node on Layer0
53
- public readonly connections: Map<NodeID, DhtNodeRpcRemote> = new Map()
53
+ public readonly connections: Map<DhtAddress, DhtNodeRpcRemote> = new Map()
54
54
  // All nodes that we know about
55
55
  private contacts: SortedContactList<DhtNodeRpcRemote>
56
56
  private randomPeers: RandomContactList<DhtNodeRpcRemote>
@@ -61,7 +61,7 @@ export class PeerManager extends EventEmitter<PeerManagerEvents> {
61
61
  super()
62
62
  this.config = config
63
63
  this.bucket = new KBucket<DhtNodeRpcRemote>({
64
- localNodeId: hexToBinary(this.config.localNodeId),
64
+ localNodeId: getRawFromDhtAddress(this.config.localNodeId),
65
65
  numberOfNodesPerKBucket: this.config.numberOfNodesPerKBucket,
66
66
  numberOfNodesToPing: this.config.numberOfNodesPerKBucket
67
67
  })
@@ -109,7 +109,7 @@ export class PeerManager extends EventEmitter<PeerManagerEvents> {
109
109
  sortingList.addContacts(oldContacts)
110
110
  const sortedContacts = sortingList.getAllContacts()
111
111
  this.config.connectionManager?.weakUnlockConnection(sortedContacts[sortedContacts.length - 1].getPeerDescriptor())
112
- this.bucket.remove(hexToBinary(sortedContacts[sortedContacts.length - 1].getNodeId()))
112
+ this.bucket.remove(getRawFromDhtAddress(sortedContacts[sortedContacts.length - 1].getNodeId()))
113
113
  this.bucket.add(newContact)
114
114
  }
115
115
 
@@ -128,7 +128,7 @@ export class PeerManager extends EventEmitter<PeerManagerEvents> {
128
128
  if (this.stopped) {
129
129
  return
130
130
  }
131
- if (!areEqualNodeIds(contact.getNodeId(), this.config.localNodeId)) {
131
+ if (contact.getNodeId() !== this.config.localNodeId) {
132
132
  // Important to lock here, before the ping result is known
133
133
  this.config.connectionManager?.weakLockConnection(contact.getPeerDescriptor())
134
134
  if (this.connections.has(contact.getNodeId())) {
@@ -166,7 +166,7 @@ export class PeerManager extends EventEmitter<PeerManagerEvents> {
166
166
 
167
167
  private getClosestActiveContactNotInBucket(): DhtNodeRpcRemote | undefined {
168
168
  for (const contactId of this.contacts.getContactIds()) {
169
- if (!this.bucket.get(hexToBinary(contactId)) && this.contacts.isActive(contactId)) {
169
+ if (!this.bucket.get(getRawFromDhtAddress(contactId)) && this.contacts.isActive(contactId)) {
170
170
  return this.contacts.getContact(contactId)!.contact
171
171
  }
172
172
  }
@@ -175,7 +175,7 @@ export class PeerManager extends EventEmitter<PeerManagerEvents> {
175
175
 
176
176
  handleConnected(peerDescriptor: PeerDescriptor): void {
177
177
  const nodeId = getNodeIdFromPeerDescriptor(peerDescriptor)
178
- if (areEqualNodeIds(nodeId, this.config.localNodeId)) {
178
+ if (nodeId === this.config.localNodeId) {
179
179
  logger.error('handleConnected() to self')
180
180
  }
181
181
  const rpcRemote = this.config.createDhtNodeRpcRemote(peerDescriptor)
@@ -212,7 +212,7 @@ export class PeerManager extends EventEmitter<PeerManagerEvents> {
212
212
  }
213
213
  logger.trace(`Removing contact ${getNodeIdFromPeerDescriptor(contact)}`)
214
214
  const nodeId = getNodeIdFromPeerDescriptor(contact)
215
- this.bucket.remove(hexToBinary(nodeId))
215
+ this.bucket.remove(getRawFromDhtAddress(nodeId))
216
216
  this.contacts.removeContact(nodeId)
217
217
  this.randomPeers.removeContact(nodeId)
218
218
  }
@@ -229,19 +229,19 @@ export class PeerManager extends EventEmitter<PeerManagerEvents> {
229
229
  this.connections.clear()
230
230
  }
231
231
 
232
- getClosestNeighborsTo(referenceId: NodeID, limit?: number, excludedNodeIds?: Set<NodeID>): DhtNodeRpcRemote[] {
232
+ getClosestNeighborsTo(referenceId: DhtAddress, limit?: number, excludedNodeIds?: Set<DhtAddress>): DhtNodeRpcRemote[] {
233
233
  const closest = new SortedContactList<DhtNodeRpcRemote>({
234
234
  referenceId,
235
235
  allowToContainReferenceId: true,
236
236
  emitEvents: false,
237
237
  excludedNodeIds
238
238
  })
239
- this.bucket.toArray().map((contact) => closest.addContact(contact))
239
+ this.bucket.toArray().forEach((contact) => closest.addContact(contact))
240
240
  return closest.getClosestContacts(limit)
241
241
  }
242
242
 
243
243
  // TODO reduce copy-paste?
244
- getClosestContactsTo(referenceId: NodeID, limit?: number, excludedNodeIds?: Set<NodeID>): DhtNodeRpcRemote[] {
244
+ getClosestContactsTo(referenceId: DhtAddress, limit?: number, excludedNodeIds?: Set<DhtAddress>): DhtNodeRpcRemote[] {
245
245
  const closest = new SortedContactList<DhtNodeRpcRemote>({
246
246
  referenceId,
247
247
  allowToContainReferenceId: true,
@@ -253,7 +253,7 @@ export class PeerManager extends EventEmitter<PeerManagerEvents> {
253
253
  return closest.getClosestContacts(limit)
254
254
  }
255
255
 
256
- getNumberOfContacts(excludedNodeIds?: Set<NodeID>): number {
256
+ getNumberOfContacts(excludedNodeIds?: Set<DhtAddress>): number {
257
257
  return this.contacts.getAllContacts().filter((contact) => {
258
258
  if (!excludedNodeIds) {
259
259
  return true
@@ -275,12 +275,12 @@ export class PeerManager extends EventEmitter<PeerManagerEvents> {
275
275
  return this.bucket.toArray().map((rpcRemote: DhtNodeRpcRemote) => rpcRemote.getPeerDescriptor())
276
276
  }
277
277
 
278
- handlePeerActive(nodeId: NodeID): void {
278
+ handlePeerActive(nodeId: DhtAddress): void {
279
279
  this.contacts.setActive(nodeId)
280
280
  }
281
281
 
282
- handlePeerUnresponsive(nodeId: NodeID): void {
283
- this.bucket.remove(hexToBinary(nodeId))
282
+ handlePeerUnresponsive(nodeId: DhtAddress): void {
283
+ this.bucket.remove(getRawFromDhtAddress(nodeId))
284
284
  this.contacts.removeContact(nodeId)
285
285
  }
286
286
 
@@ -290,7 +290,7 @@ export class PeerManager extends EventEmitter<PeerManagerEvents> {
290
290
  }
291
291
  peerDescriptors.forEach((contact) => {
292
292
  const nodeId = getNodeIdFromPeerDescriptor(contact)
293
- if (!areEqualNodeIds(nodeId, this.config.localNodeId)) {
293
+ if (nodeId !== this.config.localNodeId) {
294
294
  logger.trace(`Adding new contact ${nodeId}`)
295
295
  const remote = this.config.createDhtNodeRpcRemote(contact)
296
296
  const isInBucket = (this.bucket.get(contact.nodeId) !== null)
@@ -1,6 +1,6 @@
1
1
  import { PeerDescriptor } from '../../proto/packages/dht/protos/DhtRpc'
2
2
  import { getNodeIdFromPeerDescriptor } from '../../helpers/peerIdFromPeerDescriptor'
3
- import { NodeID } from '../../helpers/nodeId'
3
+ import { DhtAddress } from '../../identifiers'
4
4
 
5
5
  export class Contact {
6
6
 
@@ -14,7 +14,7 @@ export class Contact {
14
14
  return this.peerDescriptor
15
15
  }
16
16
 
17
- public getNodeId(): NodeID {
17
+ public getNodeId(): DhtAddress {
18
18
  return getNodeIdFromPeerDescriptor(this.peerDescriptor)
19
19
  }
20
20
  }
@@ -1,5 +1,5 @@
1
1
  import EventEmitter from 'eventemitter3'
2
- import { NodeID } from '../../helpers/nodeId'
2
+ import { DhtAddress } from '../../identifiers'
3
3
 
4
4
  export class ContactState<C> {
5
5
  public contacted = false
@@ -16,17 +16,17 @@ export interface Events<C> {
16
16
  newContact: (newContact: C, closestContacts: C[]) => void
17
17
  }
18
18
 
19
- export class ContactList<C extends { getNodeId: () => NodeID }> extends EventEmitter<Events<C>> {
19
+ export class ContactList<C extends { getNodeId: () => DhtAddress }> extends EventEmitter<Events<C>> {
20
20
 
21
- protected contactsById: Map<NodeID, ContactState<C>> = new Map()
21
+ protected contactsById: Map<DhtAddress, ContactState<C>> = new Map()
22
22
  // TODO move this to SortedContactList
23
- protected contactIds: NodeID[] = []
24
- protected localNodeId: NodeID
23
+ protected contactIds: DhtAddress[] = []
24
+ protected localNodeId: DhtAddress
25
25
  protected maxSize: number
26
26
  protected defaultContactQueryLimit
27
27
 
28
28
  constructor(
29
- localNodeId: NodeID,
29
+ localNodeId: DhtAddress,
30
30
  maxSize: number,
31
31
  defaultContactQueryLimit = 20
32
32
  ) {
@@ -36,7 +36,7 @@ export class ContactList<C extends { getNodeId: () => NodeID }> extends EventEmi
36
36
  this.defaultContactQueryLimit = defaultContactQueryLimit
37
37
  }
38
38
 
39
- public getContact(id: NodeID): ContactState<C> | undefined {
39
+ public getContact(id: DhtAddress): ContactState<C> | undefined {
40
40
  return this.contactsById.get(id)
41
41
  }
42
42
 
@@ -1,12 +1,12 @@
1
- import { NodeID, areEqualNodeIds } from '../../helpers/nodeId'
1
+ import { DhtAddress } from '../../identifiers'
2
2
  import { ContactList, ContactState } from './ContactList'
3
3
 
4
- export class RandomContactList<C extends { getNodeId: () => NodeID }> extends ContactList<C> {
4
+ export class RandomContactList<C extends { getNodeId: () => DhtAddress }> extends ContactList<C> {
5
5
 
6
6
  private randomness: number
7
7
 
8
8
  constructor(
9
- localNodeId: NodeID,
9
+ localNodeId: DhtAddress,
10
10
  maxSize: number,
11
11
  randomness = 0.20,
12
12
  defaultContactQueryLimit?: number
@@ -16,7 +16,7 @@ export class RandomContactList<C extends { getNodeId: () => NodeID }> extends Co
16
16
  }
17
17
 
18
18
  addContact(contact: C): void {
19
- if (areEqualNodeIds(this.localNodeId, contact.getNodeId())) {
19
+ if (this.localNodeId === contact.getNodeId()) {
20
20
  return
21
21
  }
22
22
  if (!this.contactsById.has(contact.getNodeId())) {
@@ -37,10 +37,10 @@ export class RandomContactList<C extends { getNodeId: () => NodeID }> extends Co
37
37
  }
38
38
  }
39
39
 
40
- removeContact(id: NodeID): boolean {
40
+ removeContact(id: DhtAddress): boolean {
41
41
  if (this.contactsById.has(id)) {
42
42
  const removed = this.contactsById.get(id)!.contact
43
- const index = this.contactIds.findIndex((nodeId) => areEqualNodeIds(nodeId, id))
43
+ const index = this.contactIds.findIndex((nodeId) => (nodeId === id))
44
44
  this.contactIds.splice(index, 1)
45
45
  this.contactsById.delete(id)
46
46
  this.emit('contactRemoved', removed, this.getContacts())
@@ -4,7 +4,6 @@ import { ConnectionType } from '../../connection/IConnection'
4
4
  import { expectedConnectionType } from '../../helpers/Connectivity'
5
5
  import { PeerDescriptor } from '../../proto/packages/dht/protos/DhtRpc'
6
6
  import { DhtRpcOptions } from '../../rpc-protocol/DhtRpcOptions'
7
- import { ServiceID } from '../../types/ServiceID'
8
7
 
9
8
  // Should connect directly to the server, timeout can be low
10
9
  const WEBSOCKET_CLIENT_TIMEOUT = 5000
@@ -32,14 +31,12 @@ export abstract class RpcRemote<T extends ServiceInfo & ClassType> {
32
31
 
33
32
  private readonly localPeerDescriptor: PeerDescriptor
34
33
  private readonly remotePeerDescriptor: PeerDescriptor
35
- private readonly serviceId: ServiceID
36
34
  private readonly client: ProtoRpcClient<T>
37
35
  private readonly timeout?: number
38
36
 
39
37
  constructor(
40
38
  localPeerDescriptor: PeerDescriptor,
41
39
  remotePeerDescriptor: PeerDescriptor,
42
- serviceId: ServiceID,
43
40
  rpcCommunicator: RpcCommunicator,
44
41
  // eslint-disable-next-line @typescript-eslint/prefer-function-type
45
42
  clientClass: { new (clientTransport: ClientTransport): T },
@@ -48,7 +45,6 @@ export abstract class RpcRemote<T extends ServiceInfo & ClassType> {
48
45
  this.localPeerDescriptor = localPeerDescriptor
49
46
  this.remotePeerDescriptor = remotePeerDescriptor
50
47
  this.client = toProtoRpcClient(new clientClass(rpcCommunicator.getRpcClientTransport()))
51
- this.serviceId = serviceId
52
48
  this.timeout = timeout
53
49
  }
54
50
 
@@ -60,10 +56,6 @@ export abstract class RpcRemote<T extends ServiceInfo & ClassType> {
60
56
  return this.localPeerDescriptor
61
57
  }
62
58
 
63
- getServiceId(): ServiceID {
64
- return this.serviceId
65
- }
66
-
67
59
  getClient(): ProtoRpcClient<T> {
68
60
  return this.client
69
61
  }