@streamr/dht 100.2.5-beta.1 → 101.0.0-beta.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 (231) hide show
  1. package/dist/package.json +7 -7
  2. package/dist/src/connection/ConnectionLockRpcLocal.d.ts +3 -3
  3. package/dist/src/connection/ConnectionLockRpcLocal.js +8 -8
  4. package/dist/src/connection/ConnectionLockRpcLocal.js.map +1 -1
  5. package/dist/src/connection/ConnectionLockRpcRemote.js +1 -1
  6. package/dist/src/connection/ConnectionLockRpcRemote.js.map +1 -1
  7. package/dist/src/connection/ConnectionManager.d.ts +4 -6
  8. package/dist/src/connection/ConnectionManager.js +128 -103
  9. package/dist/src/connection/ConnectionManager.js.map +1 -1
  10. package/dist/src/connection/ConnectorFacade.d.ts +15 -14
  11. package/dist/src/connection/ConnectorFacade.js +70 -52
  12. package/dist/src/connection/ConnectorFacade.js.map +1 -1
  13. package/dist/src/connection/Handshaker.d.ts +9 -2
  14. package/dist/src/connection/Handshaker.js +117 -27
  15. package/dist/src/connection/Handshaker.js.map +1 -1
  16. package/dist/src/connection/ManagedConnection.d.ts +13 -38
  17. package/dist/src/connection/ManagedConnection.js +31 -252
  18. package/dist/src/connection/ManagedConnection.js.map +1 -1
  19. package/dist/src/connection/OutputBuffer.d.ts +9 -0
  20. package/dist/src/connection/OutputBuffer.js +26 -0
  21. package/dist/src/connection/OutputBuffer.js.map +1 -0
  22. package/dist/src/connection/PendingConnection.d.ts +19 -0
  23. package/dist/src/connection/PendingConnection.js +59 -0
  24. package/dist/src/connection/PendingConnection.js.map +1 -0
  25. package/dist/src/connection/connectivityChecker.js +3 -3
  26. package/dist/src/connection/connectivityChecker.js.map +1 -1
  27. package/dist/src/connection/connectivityRequestHandler.js +2 -2
  28. package/dist/src/connection/connectivityRequestHandler.js.map +1 -1
  29. package/dist/src/connection/simulator/Simulator.d.ts +1 -3
  30. package/dist/src/connection/simulator/Simulator.js +1 -4
  31. package/dist/src/connection/simulator/Simulator.js.map +1 -1
  32. package/dist/src/connection/simulator/SimulatorConnection.js +1 -2
  33. package/dist/src/connection/simulator/SimulatorConnection.js.map +1 -1
  34. package/dist/src/connection/simulator/SimulatorConnector.d.ts +3 -3
  35. package/dist/src/connection/simulator/SimulatorConnector.js +28 -21
  36. package/dist/src/connection/simulator/SimulatorConnector.js.map +1 -1
  37. package/dist/src/connection/webrtc/NodeWebrtcConnection.d.ts +1 -6
  38. package/dist/src/connection/webrtc/NodeWebrtcConnection.js +3 -20
  39. package/dist/src/connection/webrtc/NodeWebrtcConnection.js.map +1 -1
  40. package/dist/src/connection/webrtc/WebrtcConnector.d.ts +11 -6
  41. package/dist/src/connection/webrtc/WebrtcConnector.js +57 -42
  42. package/dist/src/connection/webrtc/WebrtcConnector.js.map +1 -1
  43. package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.d.ts +8 -10
  44. package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js +21 -44
  45. package/dist/src/connection/webrtc/WebrtcConnectorRpcLocal.js.map +1 -1
  46. package/dist/src/connection/websocket/AbstractWebsocketClientConnection.js +8 -2
  47. package/dist/src/connection/websocket/AbstractWebsocketClientConnection.js.map +1 -1
  48. package/dist/src/connection/websocket/AutoCertifierClientFacade.d.ts +3 -3
  49. package/dist/src/connection/websocket/AutoCertifierClientFacade.js +8 -8
  50. package/dist/src/connection/websocket/AutoCertifierClientFacade.js.map +1 -1
  51. package/dist/src/connection/websocket/NodeWebsocketClientConnection.js +1 -1
  52. package/dist/src/connection/websocket/NodeWebsocketClientConnection.js.map +1 -1
  53. package/dist/src/connection/websocket/WebsocketClientConnector.d.ts +26 -0
  54. package/dist/src/connection/websocket/WebsocketClientConnector.js +86 -0
  55. package/dist/src/connection/websocket/WebsocketClientConnector.js.map +1 -0
  56. package/dist/src/connection/websocket/WebsocketClientConnectorRpcLocal.d.ts +19 -0
  57. package/dist/src/connection/websocket/WebsocketClientConnectorRpcLocal.js +23 -0
  58. package/dist/src/connection/websocket/WebsocketClientConnectorRpcLocal.js.map +1 -0
  59. package/dist/src/connection/websocket/WebsocketClientConnectorRpcRemote.d.ts +5 -0
  60. package/dist/src/connection/websocket/{WebsocketConnectorRpcRemote.js → WebsocketClientConnectorRpcRemote.js} +4 -4
  61. package/dist/src/connection/websocket/WebsocketClientConnectorRpcRemote.js.map +1 -0
  62. package/dist/src/connection/websocket/WebsocketServer.d.ts +8 -5
  63. package/dist/src/connection/websocket/WebsocketServer.js +11 -11
  64. package/dist/src/connection/websocket/WebsocketServer.js.map +1 -1
  65. package/dist/src/connection/websocket/{WebsocketConnector.d.ts → WebsocketServerConnector.d.ts} +16 -21
  66. package/dist/src/connection/websocket/{WebsocketConnector.js → WebsocketServerConnector.js} +112 -160
  67. package/dist/src/connection/websocket/WebsocketServerConnector.js.map +1 -0
  68. package/dist/src/dht/DhtNode.d.ts +4 -4
  69. package/dist/src/dht/DhtNode.js +85 -84
  70. package/dist/src/dht/DhtNode.js.map +1 -1
  71. package/dist/src/dht/DhtNodeRpcLocal.d.ts +3 -3
  72. package/dist/src/dht/DhtNodeRpcLocal.js +9 -9
  73. package/dist/src/dht/DhtNodeRpcLocal.js.map +1 -1
  74. package/dist/src/dht/ExternalApiRpcLocal.d.ts +3 -3
  75. package/dist/src/dht/ExternalApiRpcLocal.js +5 -5
  76. package/dist/src/dht/ExternalApiRpcLocal.js.map +1 -1
  77. package/dist/src/dht/ExternalApiRpcRemote.js +2 -2
  78. package/dist/src/dht/ExternalApiRpcRemote.js.map +1 -1
  79. package/dist/src/dht/PeerManager.d.ts +4 -4
  80. package/dist/src/dht/PeerManager.js +22 -22
  81. package/dist/src/dht/PeerManager.js.map +1 -1
  82. package/dist/src/dht/contact/SortedContactList.d.ts +3 -3
  83. package/dist/src/dht/contact/SortedContactList.js +9 -9
  84. package/dist/src/dht/contact/SortedContactList.js.map +1 -1
  85. package/dist/src/dht/discovery/DiscoverySession.d.ts +3 -3
  86. package/dist/src/dht/discovery/DiscoverySession.js +21 -21
  87. package/dist/src/dht/discovery/DiscoverySession.js.map +1 -1
  88. package/dist/src/dht/discovery/PeerDiscovery.d.ts +3 -3
  89. package/dist/src/dht/discovery/PeerDiscovery.js +46 -44
  90. package/dist/src/dht/discovery/PeerDiscovery.js.map +1 -1
  91. package/dist/src/dht/discovery/RingDiscoverySession.d.ts +3 -3
  92. package/dist/src/dht/discovery/RingDiscoverySession.js +19 -19
  93. package/dist/src/dht/discovery/RingDiscoverySession.js.map +1 -1
  94. package/dist/src/dht/recursive-operation/RecursiveOperationManager.d.ts +3 -3
  95. package/dist/src/dht/recursive-operation/RecursiveOperationManager.js +33 -33
  96. package/dist/src/dht/recursive-operation/RecursiveOperationManager.js.map +1 -1
  97. package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.d.ts +3 -3
  98. package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.js +8 -8
  99. package/dist/src/dht/recursive-operation/RecursiveOperationRpcLocal.js.map +1 -1
  100. package/dist/src/dht/recursive-operation/RecursiveOperationSession.d.ts +4 -4
  101. package/dist/src/dht/recursive-operation/RecursiveOperationSession.js +24 -24
  102. package/dist/src/dht/recursive-operation/RecursiveOperationSession.js.map +1 -1
  103. package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.d.ts +4 -4
  104. package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.js +5 -5
  105. package/dist/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.js.map +1 -1
  106. package/dist/src/dht/routing/Router.d.ts +3 -3
  107. package/dist/src/dht/routing/Router.js +20 -20
  108. package/dist/src/dht/routing/Router.js.map +1 -1
  109. package/dist/src/dht/routing/RouterRpcLocal.d.ts +3 -3
  110. package/dist/src/dht/routing/RouterRpcLocal.js +16 -16
  111. package/dist/src/dht/routing/RouterRpcLocal.js.map +1 -1
  112. package/dist/src/dht/routing/RoutingSession.d.ts +3 -3
  113. package/dist/src/dht/routing/RoutingSession.js +24 -24
  114. package/dist/src/dht/routing/RoutingSession.js.map +1 -1
  115. package/dist/src/dht/store/StoreManager.d.ts +3 -3
  116. package/dist/src/dht/store/StoreManager.js +25 -25
  117. package/dist/src/dht/store/StoreManager.js.map +1 -1
  118. package/dist/src/dht/store/StoreRpcLocal.d.ts +3 -3
  119. package/dist/src/dht/store/StoreRpcLocal.js +12 -12
  120. package/dist/src/dht/store/StoreRpcLocal.js.map +1 -1
  121. package/dist/src/exports.d.ts +3 -0
  122. package/dist/src/exports.js +5 -1
  123. package/dist/src/exports.js.map +1 -1
  124. package/dist/src/proto/google/protobuf/any.d.ts +5 -8
  125. package/dist/src/proto/google/protobuf/any.js.map +1 -1
  126. package/dist/src/proto/google/protobuf/empty.d.ts +1 -0
  127. package/dist/src/proto/google/protobuf/empty.js.map +1 -1
  128. package/dist/src/proto/google/protobuf/timestamp.d.ts +1 -10
  129. package/dist/src/proto/google/protobuf/timestamp.js.map +1 -1
  130. package/dist/src/proto/packages/dht/protos/DhtRpc.client.d.ts +4 -4
  131. package/dist/src/proto/packages/dht/protos/DhtRpc.client.js +8 -8
  132. package/dist/src/proto/packages/dht/protos/DhtRpc.client.js.map +1 -1
  133. package/dist/src/proto/packages/dht/protos/DhtRpc.d.ts +3 -3
  134. package/dist/src/proto/packages/dht/protos/DhtRpc.js +4 -4
  135. package/dist/src/proto/packages/dht/protos/DhtRpc.js.map +1 -1
  136. package/dist/src/proto/packages/dht/protos/DhtRpc.server.d.ts +2 -2
  137. package/dist/src/proto/packages/proto-rpc/protos/ProtoRpc.js +1 -1
  138. package/dist/src/transport/ListeningRpcCommunicator.d.ts +2 -2
  139. package/dist/src/transport/ListeningRpcCommunicator.js +2 -2
  140. package/dist/src/transport/ListeningRpcCommunicator.js.map +1 -1
  141. package/dist/src/transport/RoutingRpcCommunicator.d.ts +2 -2
  142. package/dist/src/transport/RoutingRpcCommunicator.js +2 -2
  143. package/dist/src/transport/RoutingRpcCommunicator.js.map +1 -1
  144. package/package.json +7 -7
  145. package/protos/DhtRpc.proto +1 -1
  146. package/src/connection/ConnectionLockRpcLocal.ts +9 -9
  147. package/src/connection/ConnectionLockRpcRemote.ts +1 -1
  148. package/src/connection/ConnectionManager.ts +153 -111
  149. package/src/connection/ConnectorFacade.ts +84 -61
  150. package/src/connection/Handshaker.ts +131 -27
  151. package/src/connection/ManagedConnection.ts +41 -304
  152. package/src/connection/OutputBuffer.ts +28 -0
  153. package/src/connection/PendingConnection.ts +68 -0
  154. package/src/connection/connectivityChecker.ts +2 -2
  155. package/src/connection/connectivityRequestHandler.ts +1 -1
  156. package/src/connection/simulator/Simulator.ts +1 -5
  157. package/src/connection/simulator/SimulatorConnection.ts +1 -2
  158. package/src/connection/simulator/SimulatorConnector.ts +34 -33
  159. package/src/connection/webrtc/BrowserWebrtcConnection.ts +0 -6
  160. package/src/connection/webrtc/NodeWebrtcConnection.ts +3 -24
  161. package/src/connection/webrtc/WebrtcConnector.ts +73 -62
  162. package/src/connection/webrtc/WebrtcConnectorRpcLocal.ts +26 -56
  163. package/src/connection/websocket/AbstractWebsocketClientConnection.ts +8 -2
  164. package/src/connection/websocket/AutoCertifierClientFacade.ts +11 -11
  165. package/src/connection/websocket/NodeWebsocketClientConnection.ts +1 -1
  166. package/src/connection/websocket/WebsocketClientConnector.ts +119 -0
  167. package/src/connection/websocket/WebsocketClientConnectorRpcLocal.ts +39 -0
  168. package/src/connection/websocket/{WebsocketConnectorRpcRemote.ts → WebsocketClientConnectorRpcRemote.ts} +2 -2
  169. package/src/connection/websocket/WebsocketServer.ts +18 -14
  170. package/src/connection/websocket/{WebsocketConnector.ts → WebsocketServerConnector.ts} +128 -205
  171. package/src/dht/DhtNode.ts +90 -89
  172. package/src/dht/DhtNodeRpcLocal.ts +11 -11
  173. package/src/dht/ExternalApiRpcLocal.ts +6 -6
  174. package/src/dht/ExternalApiRpcRemote.ts +2 -2
  175. package/src/dht/PeerManager.ts +24 -24
  176. package/src/dht/contact/SortedContactList.ts +10 -10
  177. package/src/dht/discovery/DiscoverySession.ts +24 -24
  178. package/src/dht/discovery/PeerDiscovery.ts +47 -45
  179. package/src/dht/discovery/RingDiscoverySession.ts +23 -23
  180. package/src/dht/recursive-operation/RecursiveOperationManager.ts +36 -36
  181. package/src/dht/recursive-operation/RecursiveOperationRpcLocal.ts +9 -9
  182. package/src/dht/recursive-operation/RecursiveOperationSession.ts +25 -25
  183. package/src/dht/recursive-operation/RecursiveOperationSessionRpcLocal.ts +7 -7
  184. package/src/dht/routing/Router.ts +21 -21
  185. package/src/dht/routing/RouterRpcLocal.ts +17 -17
  186. package/src/dht/routing/RoutingSession.ts +26 -26
  187. package/src/dht/store/StoreManager.ts +27 -27
  188. package/src/dht/store/StoreRpcLocal.ts +13 -13
  189. package/src/exports.ts +3 -0
  190. package/src/proto/google/protobuf/any.ts +6 -9
  191. package/src/proto/google/protobuf/empty.ts +2 -1
  192. package/src/proto/google/protobuf/timestamp.ts +2 -11
  193. package/src/proto/packages/dht/protos/DhtRpc.client.ts +9 -9
  194. package/src/proto/packages/dht/protos/DhtRpc.server.ts +3 -3
  195. package/src/proto/packages/dht/protos/DhtRpc.ts +4 -4
  196. package/src/proto/packages/proto-rpc/protos/ProtoRpc.ts +1 -1
  197. package/src/transport/ListeningRpcCommunicator.ts +3 -3
  198. package/src/transport/RoutingRpcCommunicator.ts +3 -3
  199. package/test/end-to-end/Layer0Webrtc.test.ts +0 -10
  200. package/test/integration/ConnectionManager.test.ts +3 -2
  201. package/test/integration/GeoIpConnectivityChecking.test.ts +1 -1
  202. package/test/integration/SimultaneousConnections.test.ts +2 -2
  203. package/test/integration/WebrtcConnectionManagement.test.ts +2 -10
  204. package/test/integration/{WebsocketConnectorRpc.test.ts → WebsocketClientConnectorRpc.test.ts} +9 -9
  205. package/test/integration/WebsocketConnectionManagement.test.ts +11 -29
  206. package/test/unit/ConnectionManager.test.ts +64 -0
  207. package/test/unit/DiscoverySession.test.ts +1 -1
  208. package/test/unit/Handshaker.test.ts +169 -0
  209. package/test/unit/ManagedConnection.test.ts +58 -0
  210. package/test/unit/PendingConnection.test.ts +57 -0
  211. package/test/unit/WebrtcConnector.test.ts +56 -0
  212. package/test/unit/{WebsocketConnector.test.ts → WebsocketClientConnector.test.ts} +56 -11
  213. package/test/unit/WebsocketServerConnector.test.ts +102 -0
  214. package/test/utils/FakeConnectorFacade.ts +41 -0
  215. package/test/utils/mock/MockConnection.ts +26 -0
  216. package/test/utils/utils.ts +2 -2
  217. package/dist/src/connection/IConnectionSource.d.ts +0 -4
  218. package/dist/src/connection/IConnectionSource.js +0 -3
  219. package/dist/src/connection/IConnectionSource.js.map +0 -1
  220. package/dist/src/connection/webrtc/ManagedWebrtcConnection.d.ts +0 -7
  221. package/dist/src/connection/webrtc/ManagedWebrtcConnection.js +0 -20
  222. package/dist/src/connection/webrtc/ManagedWebrtcConnection.js.map +0 -1
  223. package/dist/src/connection/websocket/WebsocketConnector.js.map +0 -1
  224. package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.d.ts +0 -19
  225. package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.js +0 -23
  226. package/dist/src/connection/websocket/WebsocketConnectorRpcLocal.js.map +0 -1
  227. package/dist/src/connection/websocket/WebsocketConnectorRpcRemote.d.ts +0 -5
  228. package/dist/src/connection/websocket/WebsocketConnectorRpcRemote.js.map +0 -1
  229. package/src/connection/IConnectionSource.ts +0 -6
  230. package/src/connection/webrtc/ManagedWebrtcConnection.ts +0 -27
  231. package/src/connection/websocket/WebsocketConnectorRpcLocal.ts +0 -39
@@ -17,9 +17,9 @@ import { RingIdRaw, getRingIdRawFromPeerDescriptor } from './contact/ringIdentif
17
17
 
18
18
  const logger = new Logger(module)
19
19
 
20
- interface PeerManagerConfig {
20
+ interface PeerManagerOptions {
21
21
  numberOfNodesPerKBucket: number
22
- maxContactListSize: number
22
+ maxContactCount: number
23
23
  localNodeId: DhtAddress
24
24
  localPeerDescriptor: PeerDescriptor
25
25
  connectionLocker?: ConnectionLocker
@@ -71,17 +71,17 @@ export class PeerManager extends EventEmitter<PeerManagerEvents> {
71
71
  private ringContacts: RingContactList<DhtNodeRpcRemote>
72
72
  private randomContacts: RandomContactList<DhtNodeRpcRemote>
73
73
  private stopped: boolean = false
74
- private readonly config: PeerManagerConfig
74
+ private readonly options: PeerManagerOptions
75
75
 
76
- constructor(config: PeerManagerConfig) {
76
+ constructor(options: PeerManagerOptions) {
77
77
  super()
78
- this.config = config
78
+ this.options = options
79
79
  this.neighbors = new KBucket<DhtNodeRpcRemote>({
80
- localNodeId: getRawFromDhtAddress(this.config.localNodeId),
81
- numberOfNodesPerKBucket: this.config.numberOfNodesPerKBucket,
82
- numberOfNodesToPing: this.config.numberOfNodesPerKBucket
80
+ localNodeId: getRawFromDhtAddress(this.options.localNodeId),
81
+ numberOfNodesPerKBucket: this.options.numberOfNodesPerKBucket,
82
+ numberOfNodesToPing: this.options.numberOfNodesPerKBucket
83
83
  })
84
- this.ringContacts = new RingContactList<DhtNodeRpcRemote>(getRingIdRawFromPeerDescriptor(this.config.localPeerDescriptor))
84
+ this.ringContacts = new RingContactList<DhtNodeRpcRemote>(getRingIdRawFromPeerDescriptor(this.options.localPeerDescriptor))
85
85
  this.ringContacts.on('contactAdded', (contact: DhtNodeRpcRemote) => {
86
86
  this.emit('ringContactAdded', contact.getPeerDescriptor())
87
87
  })
@@ -95,8 +95,8 @@ export class PeerManager extends EventEmitter<PeerManagerEvents> {
95
95
  // TODO: Update contact info to the connection manager and reconnect
96
96
  })
97
97
  this.nearbyContacts = new SortedContactList({
98
- referenceId: this.config.localNodeId,
99
- maxSize: this.config.maxContactListSize,
98
+ referenceId: this.options.localNodeId,
99
+ maxSize: this.options.maxContactCount,
100
100
  allowToContainReferenceId: false
101
101
  })
102
102
  this.nearbyContacts.on('contactRemoved', (contact: DhtNodeRpcRemote) => {
@@ -104,13 +104,13 @@ export class PeerManager extends EventEmitter<PeerManagerEvents> {
104
104
  return
105
105
  }
106
106
  this.emit('nearbyContactRemoved', contact.getPeerDescriptor())
107
- this.randomContacts.addContact(this.config.createDhtNodeRpcRemote(contact.getPeerDescriptor()))
107
+ this.randomContacts.addContact(this.options.createDhtNodeRpcRemote(contact.getPeerDescriptor()))
108
108
  })
109
109
  this.nearbyContacts.on('contactAdded', (contact: DhtNodeRpcRemote) =>
110
110
  this.emit('nearbyContactAdded', contact.getPeerDescriptor())
111
111
  )
112
112
  this.activeContacts = new Set()
113
- this.randomContacts = new RandomContactList(this.config.localNodeId, this.config.maxContactListSize)
113
+ this.randomContacts = new RandomContactList(this.options.localNodeId, this.options.maxContactCount)
114
114
  this.randomContacts.on('contactRemoved', (removedContact: DhtNodeRpcRemote) =>
115
115
  this.emit('randomContactRemoved', removedContact.getPeerDescriptor())
116
116
  )
@@ -124,12 +124,12 @@ export class PeerManager extends EventEmitter<PeerManagerEvents> {
124
124
  return
125
125
  }
126
126
  const sortingList: SortedContactList<DhtNodeRpcRemote> = new SortedContactList({
127
- referenceId: this.config.localNodeId,
127
+ referenceId: this.options.localNodeId,
128
128
  allowToContainReferenceId: false
129
129
  })
130
130
  sortingList.addContacts(oldContacts)
131
131
  const removableNodeId = sortingList.getFurthestContacts(1)[0].getNodeId()
132
- this.config.connectionLocker?.weakUnlockConnection(removableNodeId, this.config.lockId)
132
+ this.options.connectionLocker?.weakUnlockConnection(removableNodeId, this.options.lockId)
133
133
  this.neighbors.remove(getRawFromDhtAddress(removableNodeId))
134
134
  this.neighbors.add(newContact)
135
135
  }
@@ -138,7 +138,7 @@ export class PeerManager extends EventEmitter<PeerManagerEvents> {
138
138
  if (this.stopped) {
139
139
  return
140
140
  }
141
- this.config.connectionLocker?.weakUnlockConnection(nodeId, this.config.lockId)
141
+ this.options.connectionLocker?.weakUnlockConnection(nodeId, this.options.lockId)
142
142
  logger.trace(`Removed contact ${nodeId}`)
143
143
  if (this.neighbors.count() === 0) {
144
144
  this.emit('kBucketEmpty')
@@ -149,12 +149,12 @@ export class PeerManager extends EventEmitter<PeerManagerEvents> {
149
149
  if (this.stopped) {
150
150
  return
151
151
  }
152
- if (contact.getNodeId() !== this.config.localNodeId) {
152
+ if (contact.getNodeId() !== this.options.localNodeId) {
153
153
  const peerDescriptor = contact.getPeerDescriptor()
154
154
  const nodeId = getNodeIdFromPeerDescriptor(peerDescriptor)
155
155
  // Important to lock here, before the ping result is known
156
- this.config.connectionLocker?.weakLockConnection(nodeId, this.config.lockId)
157
- if (this.config.hasConnection(contact.getNodeId())) {
156
+ this.options.connectionLocker?.weakLockConnection(nodeId, this.options.lockId)
157
+ if (this.options.hasConnection(contact.getNodeId())) {
158
158
  logger.trace(`Added new contact ${nodeId}`)
159
159
  } else { // open connection by pinging
160
160
  logger.trace('starting ping ' + nodeId)
@@ -163,12 +163,12 @@ export class PeerManager extends EventEmitter<PeerManagerEvents> {
163
163
  logger.trace(`Added new contact ${nodeId}`)
164
164
  } else {
165
165
  logger.trace('ping failed ' + nodeId)
166
- this.config.connectionLocker?.weakUnlockConnection(nodeId, this.config.lockId)
166
+ this.options.connectionLocker?.weakUnlockConnection(nodeId, this.options.lockId)
167
167
  this.removeContact(nodeId)
168
168
  this.addNearbyContactToNeighbors()
169
169
  }
170
170
  }).catch((_e) => {
171
- this.config.connectionLocker?.weakUnlockConnection(nodeId, this.config.lockId)
171
+ this.options.connectionLocker?.weakUnlockConnection(nodeId, this.options.lockId)
172
172
  this.removeContact(nodeId)
173
173
  this.addNearbyContactToNeighbors()
174
174
  })
@@ -246,7 +246,7 @@ export class PeerManager extends EventEmitter<PeerManagerEvents> {
246
246
  ): { left: DhtNodeRpcRemote[], right: DhtNodeRpcRemote[] } {
247
247
  const closest = new RingContactList<DhtNodeRpcRemote>(ringIdRaw, excludedIds)
248
248
  this.ringContacts.getAllContacts().map((contact) => closest.addContact(contact))
249
- // TODO use config option or named constant?
249
+ // TODO use options option or named constant?
250
250
  return closest.getClosestContacts(limit ?? 8)
251
251
  }
252
252
 
@@ -279,9 +279,9 @@ export class PeerManager extends EventEmitter<PeerManagerEvents> {
279
279
  return
280
280
  }
281
281
  const nodeId = getNodeIdFromPeerDescriptor(peerDescriptor)
282
- if (nodeId !== this.config.localNodeId) {
282
+ if (nodeId !== this.options.localNodeId) {
283
283
  logger.trace(`Adding new contact ${nodeId}`)
284
- const remote = this.config.createDhtNodeRpcRemote(peerDescriptor)
284
+ const remote = this.options.createDhtNodeRpcRemote(peerDescriptor)
285
285
  const isInNeighbors = (this.neighbors.get(peerDescriptor.nodeId) !== null)
286
286
  const isInNearbyContacts = (this.nearbyContacts.getContact(nodeId) !== undefined)
287
287
  const isInRingContacts = this.ringContacts.getContact(peerDescriptor) !== undefined
@@ -8,7 +8,7 @@ import { DhtAddress, getRawFromDhtAddress } from '../../identifiers'
8
8
  export type ReadonlySortedContactList<C extends { getNodeId: () => DhtAddress }> =
9
9
  Pick<SortedContactList<C>, 'getClosestContacts' | 'getAllContactsInUndefinedOrder'>
10
10
 
11
- export interface SortedContactListConfig {
11
+ export interface SortedContactListOptions {
12
12
  referenceId: DhtAddress // all contacts in this list are in sorted by the distance to this ID
13
13
  allowToContainReferenceId: boolean
14
14
  maxSize?: number
@@ -20,15 +20,15 @@ export interface SortedContactListConfig {
20
20
 
21
21
  export class SortedContactList<C extends { getNodeId: () => DhtAddress }> extends EventEmitter<Events<C>> {
22
22
 
23
- private config: SortedContactListConfig
23
+ private options: SortedContactListOptions
24
24
  private contactsById: Map<DhtAddress, C> = new Map()
25
25
  private contactIds: DhtAddress[] = []
26
26
 
27
27
  constructor(
28
- config: SortedContactListConfig
28
+ options: SortedContactListOptions
29
29
  ) {
30
30
  super()
31
- this.config = config
31
+ this.options = options
32
32
  this.compareIds = this.compareIds.bind(this)
33
33
  }
34
34
 
@@ -42,15 +42,15 @@ export class SortedContactList<C extends { getNodeId: () => DhtAddress }> extend
42
42
 
43
43
  public addContact(contact: C): void {
44
44
  const contactId = contact.getNodeId()
45
- if (this.config.excludedNodeIds !== undefined && this.config.excludedNodeIds.has(contactId)) {
45
+ if (this.options.excludedNodeIds !== undefined && this.options.excludedNodeIds.has(contactId)) {
46
46
  return
47
47
  }
48
- if ((!this.config.allowToContainReferenceId && (this.config.referenceId === contactId)) ||
49
- (this.config.nodeIdDistanceLimit !== undefined && this.compareIds(this.config.nodeIdDistanceLimit, contactId) < 0)) {
48
+ if ((!this.options.allowToContainReferenceId && (this.options.referenceId === contactId)) ||
49
+ (this.options.nodeIdDistanceLimit !== undefined && this.compareIds(this.options.nodeIdDistanceLimit, contactId) < 0)) {
50
50
  return
51
51
  }
52
52
  if (!this.contactsById.has(contactId)) {
53
- if ((this.config.maxSize === undefined) || (this.contactIds.length < this.config.maxSize)) {
53
+ if ((this.options.maxSize === undefined) || (this.contactIds.length < this.options.maxSize)) {
54
54
  this.contactsById.set(contactId, contact)
55
55
  const index = sortedIndexBy(this.contactIds, contactId, (id: DhtAddress) => { return this.distanceToReferenceId(id) })
56
56
  this.contactIds.splice(index, 0, contactId)
@@ -60,7 +60,7 @@ export class SortedContactList<C extends { getNodeId: () => DhtAddress }> extend
60
60
  contact
61
61
  )
62
62
  }
63
- } else if (this.compareIds(this.contactIds[this.config.maxSize - 1], contactId) > 0) {
63
+ } else if (this.compareIds(this.contactIds[this.options.maxSize - 1], contactId) > 0) {
64
64
  const removedId = this.contactIds.pop()
65
65
  const removedContact = this.contactsById.get(removedId!)!
66
66
  this.contactsById.delete(removedId!)
@@ -120,7 +120,7 @@ export class SortedContactList<C extends { getNodeId: () => DhtAddress }> extend
120
120
  // TODO inline this method?
121
121
  private distanceToReferenceId(id: DhtAddress): number {
122
122
  // TODO maybe this class should store the referenceId also as DhtAddressRaw so that we don't need to convert it here?
123
- return getDistance(getRawFromDhtAddress(this.config.referenceId), getRawFromDhtAddress(id))
123
+ return getDistance(getRawFromDhtAddress(this.options.referenceId), getRawFromDhtAddress(id))
124
124
  }
125
125
 
126
126
  public removeContact(id: DhtAddress): boolean {
@@ -8,7 +8,7 @@ import { getClosestNodes } from '../contact/getClosestNodes'
8
8
 
9
9
  const logger = new Logger(module)
10
10
 
11
- interface DiscoverySessionConfig {
11
+ interface DiscoverySessionOptions {
12
12
  targetId: DhtAddress
13
13
  parallelism: number
14
14
  noProgressLimit: number
@@ -25,31 +25,31 @@ export class DiscoverySession {
25
25
  private noProgressCounter = 0
26
26
  private ongoingRequests: Set<DhtAddress> = new Set()
27
27
  private doneGate = new Gate(false)
28
- private readonly config: DiscoverySessionConfig
28
+ private readonly options: DiscoverySessionOptions
29
29
 
30
- constructor(config: DiscoverySessionConfig) {
31
- this.config = config
30
+ constructor(options: DiscoverySessionOptions) {
31
+ this.options = options
32
32
  }
33
33
 
34
34
  private addContacts(contacts: PeerDescriptor[]): void {
35
- if (this.config.abortSignal.aborted || this.doneGate.isOpen()) {
35
+ if (this.options.abortSignal.aborted || this.doneGate.isOpen()) {
36
36
  return
37
37
  }
38
38
  for (const contact of contacts) {
39
- this.config.peerManager.addContact(contact)
39
+ this.options.peerManager.addContact(contact)
40
40
  }
41
41
  }
42
42
 
43
43
  private async fetchClosestNeighborsFromRemote(peerDescriptor: PeerDescriptor): Promise<PeerDescriptor[]> {
44
- if (this.config.abortSignal.aborted || this.doneGate.isOpen()) {
44
+ if (this.options.abortSignal.aborted || this.doneGate.isOpen()) {
45
45
  return []
46
46
  }
47
47
  const nodeId = getNodeIdFromPeerDescriptor(peerDescriptor)
48
48
  logger.trace(`Getting closest neighbors from remote: ${nodeId}`)
49
- this.config.contactedPeers.add(nodeId)
50
- const remote = this.config.createDhtNodeRpcRemote(peerDescriptor)
51
- const returnedContacts = await remote.getClosestPeers(this.config.targetId)
52
- this.config.peerManager.setContactActive(nodeId)
49
+ this.options.contactedPeers.add(nodeId)
50
+ const remote = this.options.createDhtNodeRpcRemote(peerDescriptor)
51
+ const returnedContacts = await remote.getClosestPeers(this.options.targetId)
52
+ this.options.peerManager.setContactActive(nodeId)
53
53
  return returnedContacts
54
54
  }
55
55
 
@@ -58,7 +58,7 @@ export class DiscoverySession {
58
58
  return
59
59
  }
60
60
  this.ongoingRequests.delete(nodeId)
61
- const targetId = getRawFromDhtAddress(this.config.targetId)
61
+ const targetId = getRawFromDhtAddress(this.options.targetId)
62
62
  const oldClosestNeighbor = this.getClosestNeighbor()
63
63
  const oldClosestDistance = getDistance(targetId, oldClosestNeighbor.nodeId)
64
64
  this.addContacts(contacts)
@@ -71,8 +71,8 @@ export class DiscoverySession {
71
71
 
72
72
  private getClosestNeighbor(): PeerDescriptor {
73
73
  return getClosestNodes(
74
- this.config.targetId,
75
- this.config.peerManager.getNeighbors().map((n) => n.getPeerDescriptor()),
74
+ this.options.targetId,
75
+ this.options.peerManager.getNeighbors().map((n) => n.getPeerDescriptor()),
76
76
  { maxCount: 1 }
77
77
  )[0]
78
78
  }
@@ -82,27 +82,27 @@ export class DiscoverySession {
82
82
  return
83
83
  }
84
84
  this.ongoingRequests.delete(nodeId)
85
- this.config.peerManager.removeContact(nodeId)
85
+ this.options.peerManager.removeContact(nodeId)
86
86
  }
87
87
 
88
88
  private findMoreContacts(): void {
89
- if (this.config.abortSignal.aborted || this.doneGate.isOpen()) {
89
+ if (this.options.abortSignal.aborted || this.doneGate.isOpen()) {
90
90
  return
91
91
  }
92
92
  const uncontacted = getClosestNodes(
93
- this.config.targetId,
94
- Array.from(this.config.peerManager.getNearbyContacts().getAllContactsInUndefinedOrder(), (c) => c.getPeerDescriptor()),
93
+ this.options.targetId,
94
+ Array.from(this.options.peerManager.getNearbyContacts().getAllContactsInUndefinedOrder(), (c) => c.getPeerDescriptor()),
95
95
  {
96
- maxCount: this.config.parallelism,
97
- excludedNodeIds: this.config.contactedPeers
96
+ maxCount: this.options.parallelism,
97
+ excludedNodeIds: this.options.contactedPeers
98
98
  }
99
99
  )
100
- if ((uncontacted.length === 0 && this.ongoingRequests.size === 0) || (this.noProgressCounter >= this.config.noProgressLimit)) {
100
+ if ((uncontacted.length === 0 && this.ongoingRequests.size === 0) || (this.noProgressCounter >= this.options.noProgressLimit)) {
101
101
  this.doneGate.open()
102
102
  return
103
103
  }
104
104
  for (const node of uncontacted) {
105
- if (this.ongoingRequests.size >= this.config.parallelism) {
105
+ if (this.ongoingRequests.size >= this.options.parallelism) {
106
106
  break
107
107
  }
108
108
  const nodeId = getNodeIdFromPeerDescriptor(node)
@@ -118,12 +118,12 @@ export class DiscoverySession {
118
118
  }
119
119
 
120
120
  public async findClosestNodes(timeout: number): Promise<void> {
121
- if (this.config.peerManager.getNearbyContactCount(this.config.contactedPeers) === 0) {
121
+ if (this.options.peerManager.getNearbyContactCount(this.options.contactedPeers) === 0) {
122
122
  return
123
123
  }
124
124
  setImmediate(() => {
125
125
  this.findMoreContacts()
126
126
  })
127
- await withTimeout(this.doneGate.waitUntilOpen(), timeout, 'discovery session timed out', this.config.abortSignal)
127
+ await withTimeout(this.doneGate.waitUntilOpen(), timeout, 'discovery session timed out', this.options.abortSignal)
128
128
  }
129
129
  }
@@ -16,8 +16,9 @@ import { getClosestNodes } from '../contact/getClosestNodes'
16
16
  import { RingIdRaw, getRingIdRawFromPeerDescriptor } from '../contact/ringIdentifiers'
17
17
  import { DiscoverySession } from './DiscoverySession'
18
18
  import { RingDiscoverySession } from './RingDiscoverySession'
19
+ import { CONTROL_LAYER_NODE_SERVICE_ID } from '../DhtNode'
19
20
 
20
- interface PeerDiscoveryConfig {
21
+ interface PeerDiscoveryOptions {
21
22
  localPeerDescriptor: PeerDescriptor
22
23
  joinNoProgressLimit: number
23
24
  serviceId: ServiceID
@@ -45,10 +46,10 @@ export class PeerDiscovery {
45
46
  private rejoinOngoing = false
46
47
  private joinCalled = false
47
48
  private recoveryIntervalStarted = false
48
- private readonly config: PeerDiscoveryConfig
49
+ private readonly options: PeerDiscoveryOptions
49
50
 
50
- constructor(config: PeerDiscoveryConfig) {
51
- this.config = config
51
+ constructor(options: PeerDiscoveryOptions) {
52
+ this.options = options
52
53
  }
53
54
 
54
55
  async joinDht(
@@ -57,12 +58,12 @@ export class PeerDiscovery {
57
58
  retry = true
58
59
  ): Promise<void> {
59
60
  const contactedPeers = new Set<DhtAddress>()
60
- const distantJoinConfig = doAdditionalDistantPeerDiscovery
61
+ const distantJoinOptions = doAdditionalDistantPeerDiscovery
61
62
  ? { enabled: true, contactedPeers: new Set<DhtAddress>() } : { enabled: false } as const
62
63
  await Promise.all(entryPoints.map((entryPoint) => this.joinThroughEntryPoint(
63
64
  entryPoint,
64
65
  contactedPeers,
65
- distantJoinConfig,
66
+ distantJoinOptions,
66
67
  retry
67
68
  )))
68
69
  }
@@ -79,39 +80,40 @@ export class PeerDiscovery {
79
80
  }
80
81
  this.joinCalled = true
81
82
  logger.debug(
82
- `Joining ${this.config.serviceId === 'layer0' ? 'The Streamr Network' : `Control Layer for ${this.config.serviceId}`}`
83
+ `Joining ${this.options.serviceId === CONTROL_LAYER_NODE_SERVICE_ID
84
+ ? 'The Streamr Network' : `Control Layer for ${this.options.serviceId}`}`
83
85
  + ` via entrypoint ${getNodeIdFromPeerDescriptor(entryPointDescriptor)}`
84
86
  )
85
- if (areEqualPeerDescriptors(entryPointDescriptor, this.config.localPeerDescriptor)) {
87
+ if (areEqualPeerDescriptors(entryPointDescriptor, this.options.localPeerDescriptor)) {
86
88
  return
87
89
  }
88
- this.config.connectionLocker?.lockConnection(entryPointDescriptor, `${this.config.serviceId}::joinDht`)
89
- this.config.peerManager.addContact(entryPointDescriptor)
90
- const targetId = getNodeIdFromPeerDescriptor(this.config.localPeerDescriptor)
90
+ this.options.connectionLocker?.lockConnection(entryPointDescriptor, `${this.options.serviceId}::joinDht`)
91
+ this.options.peerManager.addContact(entryPointDescriptor)
92
+ const targetId = getNodeIdFromPeerDescriptor(this.options.localPeerDescriptor)
91
93
  const sessions = [this.createSession(targetId, contactedPeers)]
92
94
  if (additionalDistantJoin.enabled) {
93
95
  sessions.push(this.createSession(createDistantDhtAddress(targetId), additionalDistantJoin.contactedPeers))
94
96
  }
95
97
  await this.runSessions(sessions, entryPointDescriptor, retry)
96
- this.config.connectionLocker?.unlockConnection(entryPointDescriptor, `${this.config.serviceId}::joinDht`)
98
+ this.options.connectionLocker?.unlockConnection(entryPointDescriptor, `${this.options.serviceId}::joinDht`)
97
99
 
98
100
  }
99
101
 
100
102
  async joinRing(): Promise<void> {
101
103
  const contactedPeers = new Set<DhtAddress>()
102
- const sessions = [this.createRingSession(getRingIdRawFromPeerDescriptor(this.config.localPeerDescriptor), contactedPeers)]
104
+ const sessions = [this.createRingSession(getRingIdRawFromPeerDescriptor(this.options.localPeerDescriptor), contactedPeers)]
103
105
  await this.runRingSessions(sessions)
104
106
  }
105
107
 
106
108
  private createSession(targetId: DhtAddress, contactedPeers: Set<DhtAddress>): DiscoverySession {
107
109
  const sessionOptions = {
108
110
  targetId,
109
- parallelism: this.config.parallelism,
110
- noProgressLimit: this.config.joinNoProgressLimit,
111
- peerManager: this.config.peerManager,
111
+ parallelism: this.options.parallelism,
112
+ noProgressLimit: this.options.joinNoProgressLimit,
113
+ peerManager: this.options.peerManager,
112
114
  contactedPeers,
113
- abortSignal: this.config.abortSignal,
114
- createDhtNodeRpcRemote: this.config.createDhtNodeRpcRemote
115
+ abortSignal: this.options.abortSignal,
116
+ createDhtNodeRpcRemote: this.options.createDhtNodeRpcRemote
115
117
  }
116
118
  return new DiscoverySession(sessionOptions)
117
119
  }
@@ -119,12 +121,12 @@ export class PeerDiscovery {
119
121
  private createRingSession(targetId: RingIdRaw, contactedPeers: Set<DhtAddress>): RingDiscoverySession {
120
122
  const sessionOptions = {
121
123
  targetId,
122
- parallelism: this.config.parallelism,
123
- noProgressLimit: this.config.joinNoProgressLimit,
124
- peerManager: this.config.peerManager,
124
+ parallelism: this.options.parallelism,
125
+ noProgressLimit: this.options.joinNoProgressLimit,
126
+ peerManager: this.options.peerManager,
125
127
  contactedPeers,
126
- abortSignal: this.config.abortSignal,
127
- createDhtNodeRpcRemote: this.config.createDhtNodeRpcRemote
128
+ abortSignal: this.options.abortSignal,
129
+ createDhtNodeRpcRemote: this.options.createDhtNodeRpcRemote
128
130
  }
129
131
  return new RingDiscoverySession(sessionOptions)
130
132
  }
@@ -133,17 +135,17 @@ export class PeerDiscovery {
133
135
  try {
134
136
  for (const session of sessions) {
135
137
  this.ongoingDiscoverySessions.set(session.id, session)
136
- await session.findClosestNodes(this.config.joinTimeout)
138
+ await session.findClosestNodes(this.options.joinTimeout)
137
139
  }
138
140
  } catch (_e) {
139
- logger.debug(`DHT join on ${this.config.serviceId} timed out`)
141
+ logger.debug(`DHT join on ${this.options.serviceId} timed out`)
140
142
  } finally {
141
143
  if (!this.isStopped()) {
142
- if (this.config.peerManager.getNeighborCount() === 0) {
144
+ if (this.options.peerManager.getNeighborCount() === 0) {
143
145
  if (retry) {
144
146
  // TODO should we catch possible promise rejection?
145
- // TODO use config option or named constant?
146
- setAbortableTimeout(() => this.rejoinDht(entryPointDescriptor), 1000, this.config.abortSignal)
147
+ // TODO use options option or named constant?
148
+ setAbortableTimeout(() => this.rejoinDht(entryPointDescriptor), 1000, this.options.abortSignal)
147
149
  }
148
150
  } else {
149
151
  await this.ensureRecoveryIntervalIsRunning()
@@ -157,10 +159,10 @@ export class PeerDiscovery {
157
159
  try {
158
160
  for (const session of sessions) {
159
161
  this.ongoingRingDiscoverySessions.set(session.id, session)
160
- await session.findClosestNodes(this.config.joinTimeout)
162
+ await session.findClosestNodes(this.options.joinTimeout)
161
163
  }
162
164
  } catch (_e) {
163
- logger.debug(`Ring join on ${this.config.serviceId} timed out`)
165
+ logger.debug(`Ring join on ${this.options.serviceId} timed out`)
164
166
  } finally {
165
167
  sessions.forEach((session) => this.ongoingDiscoverySessions.delete(session.id))
166
168
  }
@@ -174,17 +176,17 @@ export class PeerDiscovery {
174
176
  if (this.isStopped() || this.rejoinOngoing) {
175
177
  return
176
178
  }
177
- logger.debug(`Rejoining DHT ${this.config.serviceId}`)
179
+ logger.debug(`Rejoining DHT ${this.options.serviceId}`)
178
180
  this.rejoinOngoing = true
179
181
  try {
180
182
  await this.joinThroughEntryPoint(entryPoint, contactedPeers, { enabled: true, contactedPeers: distantJoinContactPeers })
181
- logger.debug(`Rejoined DHT successfully ${this.config.serviceId}!`)
183
+ logger.debug(`Rejoined DHT successfully ${this.options.serviceId}!`)
182
184
  } catch (err) {
183
- logger.warn(`Rejoining DHT ${this.config.serviceId} failed`)
185
+ logger.warn(`Rejoining DHT ${this.options.serviceId} failed`)
184
186
  if (!this.isStopped()) {
185
187
  // TODO should we catch possible promise rejection?
186
- // TODO use config option or named constant?
187
- setAbortableTimeout(() => this.rejoinDht(entryPoint), 5000, this.config.abortSignal)
188
+ // TODO use options option or named constant?
189
+ setAbortableTimeout(() => this.rejoinDht(entryPoint), 5000, this.options.abortSignal)
188
190
  }
189
191
  } finally {
190
192
  this.rejoinOngoing = false
@@ -194,8 +196,8 @@ export class PeerDiscovery {
194
196
  private async ensureRecoveryIntervalIsRunning(): Promise<void> {
195
197
  if (!this.recoveryIntervalStarted) {
196
198
  this.recoveryIntervalStarted = true
197
- // TODO use config option or named constant?
198
- await scheduleAtInterval(() => this.fetchClosestAndRandomNeighbors(), 60000, true, this.config.abortSignal)
199
+ // TODO use options option or named constant?
200
+ await scheduleAtInterval(() => this.fetchClosestAndRandomNeighbors(), 60000, true, this.options.abortSignal)
199
201
  }
200
202
  }
201
203
 
@@ -203,29 +205,29 @@ export class PeerDiscovery {
203
205
  if (this.isStopped()) {
204
206
  return
205
207
  }
206
- const localNodeId = getNodeIdFromPeerDescriptor(this.config.localPeerDescriptor)
207
- const nodes = this.getClosestNeighbors(localNodeId, this.config.parallelism)
208
+ const localNodeId = getNodeIdFromPeerDescriptor(this.options.localPeerDescriptor)
209
+ const nodes = this.getClosestNeighbors(localNodeId, this.options.parallelism)
208
210
  const randomNodes = this.getClosestNeighbors(createRandomDhtAddress(), 1)
209
211
  await Promise.allSettled([
210
212
  ...nodes.map(async (node: PeerDescriptor) => {
211
- const remote = this.config.createDhtNodeRpcRemote(node)
213
+ const remote = this.options.createDhtNodeRpcRemote(node)
212
214
  const contacts = await remote.getClosestPeers(localNodeId)
213
215
  for (const contact of contacts) {
214
- this.config.peerManager.addContact(contact)
216
+ this.options.peerManager.addContact(contact)
215
217
  }
216
218
  }),
217
219
  ...randomNodes.map(async (node: PeerDescriptor) => {
218
- const remote = this.config.createDhtNodeRpcRemote(node)
220
+ const remote = this.options.createDhtNodeRpcRemote(node)
219
221
  const contacts = await remote.getClosestPeers(createRandomDhtAddress())
220
222
  for (const contact of contacts) {
221
- this.config.peerManager.addContact(contact)
223
+ this.options.peerManager.addContact(contact)
222
224
  }
223
225
  })
224
226
  ])
225
227
  }
226
228
 
227
229
  private getClosestNeighbors(referenceId: DhtAddress, maxCount: number): PeerDescriptor[] {
228
- return getClosestNodes(referenceId, this.config.peerManager.getNeighbors().map((n) => n.getPeerDescriptor()), { maxCount })
230
+ return getClosestNodes(referenceId, this.options.peerManager.getNeighbors().map((n) => n.getPeerDescriptor()), { maxCount })
229
231
  }
230
232
 
231
233
  public isJoinOngoing(): boolean {
@@ -237,6 +239,6 @@ export class PeerDiscovery {
237
239
  }
238
240
 
239
241
  private isStopped() {
240
- return this.config.abortSignal.aborted
242
+ return this.options.abortSignal.aborted
241
243
  }
242
244
  }