libp2p 0.43.3 → 0.43.4-20c8ed4b

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 (187) hide show
  1. package/dist/index.min.js +30 -30
  2. package/dist/src/autonat/index.d.ts +1 -2
  3. package/dist/src/autonat/index.d.ts.map +1 -1
  4. package/dist/src/autonat/index.js +1 -3
  5. package/dist/src/autonat/index.js.map +1 -1
  6. package/dist/src/circuit-relay/constants.d.ts.map +1 -0
  7. package/dist/src/circuit-relay/constants.js.map +1 -0
  8. package/dist/src/circuit-relay/index.d.ts.map +1 -0
  9. package/dist/src/circuit-relay/index.js.map +1 -0
  10. package/dist/src/circuit-relay/pb/index.d.ts.map +1 -0
  11. package/dist/src/circuit-relay/pb/index.js.map +1 -0
  12. package/dist/src/circuit-relay/server/advert-service.d.ts.map +1 -0
  13. package/dist/src/circuit-relay/server/advert-service.js.map +1 -0
  14. package/dist/src/circuit-relay/server/index.d.ts.map +1 -0
  15. package/dist/src/circuit-relay/server/index.js.map +1 -0
  16. package/dist/src/circuit-relay/server/reservation-store.d.ts.map +1 -0
  17. package/dist/src/circuit-relay/server/reservation-store.js.map +1 -0
  18. package/dist/src/circuit-relay/server/reservation-voucher.d.ts.map +1 -0
  19. package/dist/src/circuit-relay/server/reservation-voucher.js.map +1 -0
  20. package/dist/src/circuit-relay/transport/discovery.d.ts.map +1 -0
  21. package/dist/src/circuit-relay/transport/discovery.js.map +1 -0
  22. package/dist/src/circuit-relay/transport/index.d.ts.map +1 -0
  23. package/dist/src/circuit-relay/transport/index.js.map +1 -0
  24. package/dist/src/circuit-relay/transport/listener.d.ts.map +1 -0
  25. package/dist/src/circuit-relay/transport/listener.js.map +1 -0
  26. package/dist/src/{circuit → circuit-relay}/transport/reservation-store.d.ts +1 -1
  27. package/dist/src/circuit-relay/transport/reservation-store.d.ts.map +1 -0
  28. package/dist/src/circuit-relay/transport/reservation-store.js.map +1 -0
  29. package/dist/src/circuit-relay/utils.d.ts.map +1 -0
  30. package/dist/src/{circuit → circuit-relay}/utils.js +3 -1
  31. package/dist/src/circuit-relay/utils.js.map +1 -0
  32. package/dist/src/components.d.ts +1 -6
  33. package/dist/src/components.d.ts.map +1 -1
  34. package/dist/src/components.js +0 -10
  35. package/dist/src/components.js.map +1 -1
  36. package/dist/src/config.d.ts.map +1 -1
  37. package/dist/src/config.js +0 -9
  38. package/dist/src/config.js.map +1 -1
  39. package/dist/src/connection-manager/auto-dial.d.ts +36 -0
  40. package/dist/src/connection-manager/auto-dial.d.ts.map +1 -0
  41. package/dist/src/connection-manager/auto-dial.js +122 -0
  42. package/dist/src/connection-manager/auto-dial.js.map +1 -0
  43. package/dist/src/connection-manager/connection-pruner.d.ts +28 -0
  44. package/dist/src/connection-manager/connection-pruner.d.ts.map +1 -0
  45. package/dist/src/connection-manager/connection-pruner.js +96 -0
  46. package/dist/src/connection-manager/connection-pruner.js.map +1 -0
  47. package/dist/src/connection-manager/constants.d.ts +49 -0
  48. package/dist/src/connection-manager/constants.d.ts.map +1 -0
  49. package/dist/src/connection-manager/constants.js +49 -0
  50. package/dist/src/connection-manager/constants.js.map +1 -0
  51. package/dist/src/connection-manager/dial-queue.d.ts +77 -0
  52. package/dist/src/connection-manager/dial-queue.d.ts.map +1 -0
  53. package/dist/src/connection-manager/dial-queue.js +366 -0
  54. package/dist/src/connection-manager/dial-queue.js.map +1 -0
  55. package/dist/src/connection-manager/index.d.ts +65 -69
  56. package/dist/src/connection-manager/index.d.ts.map +1 -1
  57. package/dist/src/connection-manager/index.js +116 -229
  58. package/dist/src/connection-manager/index.js.map +1 -1
  59. package/dist/src/connection-manager/utils.d.ts +9 -0
  60. package/dist/src/connection-manager/utils.d.ts.map +1 -0
  61. package/dist/src/connection-manager/utils.js +66 -0
  62. package/dist/src/connection-manager/utils.js.map +1 -0
  63. package/dist/src/content-routing/utils.js +1 -1
  64. package/dist/src/content-routing/utils.js.map +1 -1
  65. package/dist/src/get-peer.d.ts +6 -5
  66. package/dist/src/get-peer.d.ts.map +1 -1
  67. package/dist/src/get-peer.js +34 -12
  68. package/dist/src/get-peer.js.map +1 -1
  69. package/dist/src/identify/index.js +1 -1
  70. package/dist/src/identify/index.js.map +1 -1
  71. package/dist/src/index.d.ts +1 -1
  72. package/dist/src/index.d.ts.map +1 -1
  73. package/dist/src/libp2p.d.ts +13 -5
  74. package/dist/src/libp2p.d.ts.map +1 -1
  75. package/dist/src/libp2p.js +8 -12
  76. package/dist/src/libp2p.js.map +1 -1
  77. package/dist/src/upgrader.d.ts +1 -1
  78. package/dist/src/upgrader.d.ts.map +1 -1
  79. package/dist/src/upgrader.js +2 -1
  80. package/dist/src/upgrader.js.map +1 -1
  81. package/package.json +14 -14
  82. package/src/autonat/index.ts +2 -5
  83. package/src/{circuit → circuit-relay}/transport/reservation-store.ts +1 -1
  84. package/src/{circuit → circuit-relay}/utils.ts +3 -1
  85. package/src/components.ts +1 -17
  86. package/src/config.ts +0 -9
  87. package/src/connection-manager/auto-dial.ts +171 -0
  88. package/src/connection-manager/connection-pruner.ts +137 -0
  89. package/src/connection-manager/constants.ts +60 -0
  90. package/src/connection-manager/dial-queue.ts +504 -0
  91. package/src/connection-manager/index.ts +190 -319
  92. package/src/connection-manager/utils.ts +76 -0
  93. package/src/content-routing/utils.ts +1 -1
  94. package/src/get-peer.ts +45 -15
  95. package/src/identify/index.ts +1 -1
  96. package/src/index.ts +1 -1
  97. package/src/libp2p.ts +21 -17
  98. package/src/upgrader.ts +3 -2
  99. package/src/version.ts +1 -1
  100. package/dist/src/circuit/constants.d.ts.map +0 -1
  101. package/dist/src/circuit/constants.js.map +0 -1
  102. package/dist/src/circuit/index.d.ts.map +0 -1
  103. package/dist/src/circuit/index.js.map +0 -1
  104. package/dist/src/circuit/pb/index.d.ts.map +0 -1
  105. package/dist/src/circuit/pb/index.js.map +0 -1
  106. package/dist/src/circuit/server/advert-service.d.ts.map +0 -1
  107. package/dist/src/circuit/server/advert-service.js.map +0 -1
  108. package/dist/src/circuit/server/index.d.ts.map +0 -1
  109. package/dist/src/circuit/server/index.js.map +0 -1
  110. package/dist/src/circuit/server/reservation-store.d.ts.map +0 -1
  111. package/dist/src/circuit/server/reservation-store.js.map +0 -1
  112. package/dist/src/circuit/server/reservation-voucher.d.ts.map +0 -1
  113. package/dist/src/circuit/server/reservation-voucher.js.map +0 -1
  114. package/dist/src/circuit/transport/discovery.d.ts.map +0 -1
  115. package/dist/src/circuit/transport/discovery.js.map +0 -1
  116. package/dist/src/circuit/transport/index.d.ts.map +0 -1
  117. package/dist/src/circuit/transport/index.js.map +0 -1
  118. package/dist/src/circuit/transport/listener.d.ts.map +0 -1
  119. package/dist/src/circuit/transport/listener.js.map +0 -1
  120. package/dist/src/circuit/transport/reservation-store.d.ts.map +0 -1
  121. package/dist/src/circuit/transport/reservation-store.js.map +0 -1
  122. package/dist/src/circuit/utils.d.ts.map +0 -1
  123. package/dist/src/circuit/utils.js.map +0 -1
  124. package/dist/src/connection-manager/auto-dialler.d.ts +0 -42
  125. package/dist/src/connection-manager/auto-dialler.d.ts.map +0 -1
  126. package/dist/src/connection-manager/auto-dialler.js +0 -105
  127. package/dist/src/connection-manager/auto-dialler.js.map +0 -1
  128. package/dist/src/connection-manager/dialer/dial-request.d.ts +0 -27
  129. package/dist/src/connection-manager/dialer/dial-request.d.ts.map +0 -1
  130. package/dist/src/connection-manager/dialer/dial-request.js +0 -114
  131. package/dist/src/connection-manager/dialer/dial-request.js.map +0 -1
  132. package/dist/src/connection-manager/dialer/index.d.ts +0 -122
  133. package/dist/src/connection-manager/dialer/index.d.ts.map +0 -1
  134. package/dist/src/connection-manager/dialer/index.js +0 -321
  135. package/dist/src/connection-manager/dialer/index.js.map +0 -1
  136. package/dist/src/connection-manager/latency-monitor.d.ts +0 -120
  137. package/dist/src/connection-manager/latency-monitor.d.ts.map +0 -1
  138. package/dist/src/connection-manager/latency-monitor.js +0 -220
  139. package/dist/src/connection-manager/latency-monitor.js.map +0 -1
  140. package/dist/src/connection-manager/visibility-change-emitter.d.ts +0 -66
  141. package/dist/src/connection-manager/visibility-change-emitter.d.ts.map +0 -1
  142. package/dist/src/connection-manager/visibility-change-emitter.js +0 -118
  143. package/dist/src/connection-manager/visibility-change-emitter.js.map +0 -1
  144. package/dist/src/constants.d.ts +0 -27
  145. package/dist/src/constants.d.ts.map +0 -1
  146. package/dist/src/constants.js +0 -31
  147. package/dist/src/constants.js.map +0 -1
  148. package/dist/typedoc-urls.json +0 -41
  149. package/src/connection-manager/auto-dialler.ts +0 -158
  150. package/src/connection-manager/dialer/dial-request.ts +0 -144
  151. package/src/connection-manager/dialer/index.ts +0 -457
  152. package/src/connection-manager/latency-monitor.ts +0 -319
  153. package/src/connection-manager/visibility-change-emitter.ts +0 -135
  154. package/src/constants.ts +0 -36
  155. /package/dist/src/{circuit → circuit-relay}/constants.d.ts +0 -0
  156. /package/dist/src/{circuit → circuit-relay}/constants.js +0 -0
  157. /package/dist/src/{circuit → circuit-relay}/index.d.ts +0 -0
  158. /package/dist/src/{circuit → circuit-relay}/index.js +0 -0
  159. /package/dist/src/{circuit → circuit-relay}/pb/index.d.ts +0 -0
  160. /package/dist/src/{circuit → circuit-relay}/pb/index.js +0 -0
  161. /package/dist/src/{circuit → circuit-relay}/server/advert-service.d.ts +0 -0
  162. /package/dist/src/{circuit → circuit-relay}/server/advert-service.js +0 -0
  163. /package/dist/src/{circuit → circuit-relay}/server/index.d.ts +0 -0
  164. /package/dist/src/{circuit → circuit-relay}/server/index.js +0 -0
  165. /package/dist/src/{circuit → circuit-relay}/server/reservation-store.d.ts +0 -0
  166. /package/dist/src/{circuit → circuit-relay}/server/reservation-store.js +0 -0
  167. /package/dist/src/{circuit → circuit-relay}/server/reservation-voucher.d.ts +0 -0
  168. /package/dist/src/{circuit → circuit-relay}/server/reservation-voucher.js +0 -0
  169. /package/dist/src/{circuit → circuit-relay}/transport/discovery.d.ts +0 -0
  170. /package/dist/src/{circuit → circuit-relay}/transport/discovery.js +0 -0
  171. /package/dist/src/{circuit → circuit-relay}/transport/index.d.ts +0 -0
  172. /package/dist/src/{circuit → circuit-relay}/transport/index.js +0 -0
  173. /package/dist/src/{circuit → circuit-relay}/transport/listener.d.ts +0 -0
  174. /package/dist/src/{circuit → circuit-relay}/transport/listener.js +0 -0
  175. /package/dist/src/{circuit → circuit-relay}/transport/reservation-store.js +0 -0
  176. /package/dist/src/{circuit → circuit-relay}/utils.d.ts +0 -0
  177. /package/src/{circuit → circuit-relay}/constants.ts +0 -0
  178. /package/src/{circuit → circuit-relay}/index.ts +0 -0
  179. /package/src/{circuit → circuit-relay}/pb/index.proto +0 -0
  180. /package/src/{circuit → circuit-relay}/pb/index.ts +0 -0
  181. /package/src/{circuit → circuit-relay}/server/advert-service.ts +0 -0
  182. /package/src/{circuit → circuit-relay}/server/index.ts +0 -0
  183. /package/src/{circuit → circuit-relay}/server/reservation-store.ts +0 -0
  184. /package/src/{circuit → circuit-relay}/server/reservation-voucher.ts +0 -0
  185. /package/src/{circuit → circuit-relay}/transport/discovery.ts +0 -0
  186. /package/src/{circuit → circuit-relay}/transport/index.ts +0 -0
  187. /package/src/{circuit → circuit-relay}/transport/listener.ts +0 -0
@@ -1,68 +1,112 @@
1
1
  import { logger } from '@libp2p/logger';
2
2
  import { CodeError } from '@libp2p/interfaces/errors';
3
- import mergeOptions from 'merge-options';
4
- import { LatencyMonitor } from './latency-monitor.js';
5
3
  import { CustomEvent, EventEmitter } from '@libp2p/interfaces/events';
6
4
  import { codes } from '../errors.js';
7
- import { isPeerId } from '@libp2p/interface-peer-id';
8
5
  import { setMaxListeners } from 'events';
9
- import * as STATUS from '@libp2p/interface-connection/status';
10
6
  import { multiaddr } from '@multiformats/multiaddr';
11
- import { PeerMap } from '@libp2p/peer-collections';
12
- import { TimeoutController } from 'timeout-abort-controller';
13
7
  import { KEEP_ALIVE } from '@libp2p/interface-peer-store/tags';
14
8
  import { RateLimiterMemory } from 'rate-limiter-flexible';
15
9
  import { getPeerAddress } from '../get-peer.js';
10
+ import { AutoDial } from './auto-dial.js';
11
+ import { DialQueue } from './dial-queue.js';
12
+ import { ConnectionPruner } from './connection-pruner.js';
13
+ import { PeerMap } from '@libp2p/peer-collections';
14
+ import { publicAddressesFirst } from '@libp2p/utils/address-sort';
15
+ import { AUTO_DIAL_CONCURRENCY, AUTO_DIAL_PRIORITY, DIAL_TIMEOUT, INBOUND_CONNECTION_THRESHOLD, MAX_CONNECTIONS, MAX_INCOMING_PENDING_CONNECTIONS, MAX_PARALLEL_DIALS, MAX_PEER_ADDRS_TO_DIAL, MIN_CONNECTIONS } from './constants.js';
16
+ import { dnsaddrResolver } from '@multiformats/multiaddr/resolvers';
16
17
  const log = logger('libp2p:connection-manager');
18
+ const DEFAULT_DIAL_PRIORITY = 50;
17
19
  const defaultOptions = {
18
- maxConnections: Infinity,
19
- minConnections: 0,
20
- maxEventLoopDelay: Infinity,
21
- pollInterval: 2000,
22
- autoDialInterval: 10000,
23
- inboundConnectionThreshold: 5,
24
- maxIncomingPendingConnections: 10
20
+ minConnections: MIN_CONNECTIONS,
21
+ maxConnections: MAX_CONNECTIONS,
22
+ inboundConnectionThreshold: INBOUND_CONNECTION_THRESHOLD,
23
+ maxIncomingPendingConnections: MAX_INCOMING_PENDING_CONNECTIONS,
24
+ autoDialConcurrency: AUTO_DIAL_CONCURRENCY,
25
+ autoDialPriority: AUTO_DIAL_PRIORITY
25
26
  };
26
- const STARTUP_RECONNECT_TIMEOUT = 60000;
27
27
  /**
28
28
  * Responsible for managing known connections.
29
29
  */
30
30
  export class DefaultConnectionManager extends EventEmitter {
31
- constructor(components, init) {
31
+ constructor(components, init = {}) {
32
32
  super();
33
- this.opts = mergeOptions.call({ ignoreUndefined: true }, defaultOptions, init);
34
- if (this.opts.maxConnections < this.opts.minConnections) {
33
+ this.maxConnections = init.maxConnections ?? defaultOptions.maxConnections;
34
+ const minConnections = init.minConnections ?? defaultOptions.minConnections;
35
+ if (this.maxConnections < minConnections) {
35
36
  throw new CodeError('Connection Manager maxConnections must be greater than minConnections', codes.ERR_INVALID_PARAMETERS);
36
37
  }
37
- log('options: %o', this.opts);
38
- this.components = components;
39
38
  /**
40
39
  * Map of connections per peer
41
40
  */
42
- this.connections = new Map();
41
+ this.connections = new PeerMap();
43
42
  this.started = false;
44
- if (init.maxEventLoopDelay != null && init.maxEventLoopDelay > 0 && init.maxEventLoopDelay !== Infinity) {
45
- this.latencyMonitor = new LatencyMonitor({
46
- latencyCheckIntervalMs: init.pollInterval,
47
- dataEmitIntervalMs: init.pollInterval
48
- });
49
- }
50
43
  try {
51
44
  // This emitter gets listened to a lot
52
45
  setMaxListeners?.(Infinity, this);
53
46
  }
54
47
  catch { }
48
+ this.peerStore = components.peerStore;
49
+ this.metrics = components.metrics;
55
50
  this.onConnect = this.onConnect.bind(this);
56
51
  this.onDisconnect = this.onDisconnect.bind(this);
57
- this.startupReconnectTimeout = init.startupReconnectTimeout ?? STARTUP_RECONNECT_TIMEOUT;
58
- this.dialTimeout = init.dialTimeout ?? 30000;
52
+ // allow/deny lists
59
53
  this.allow = (init.allow ?? []).map(ma => multiaddr(ma));
60
54
  this.deny = (init.deny ?? []).map(ma => multiaddr(ma));
55
+ this.incomingPendingConnections = 0;
56
+ this.maxIncomingPendingConnections = init.maxIncomingPendingConnections ?? defaultOptions.maxIncomingPendingConnections;
57
+ // controls individual peers trying to dial us too quickly
61
58
  this.inboundConnectionRateLimiter = new RateLimiterMemory({
62
- points: this.opts.inboundConnectionThreshold,
59
+ points: init.inboundConnectionThreshold ?? defaultOptions.inboundConnectionThreshold,
63
60
  duration: 1
64
61
  });
65
- this.incomingPendingConnections = 0;
62
+ // controls what happens when we don't have enough connections
63
+ this.autoDial = new AutoDial({
64
+ connectionManager: this,
65
+ peerStore: components.peerStore
66
+ }, {
67
+ minConnections,
68
+ autoDialConcurrency: init.autoDialConcurrency ?? defaultOptions.autoDialConcurrency,
69
+ autoDialPriority: init.autoDialPriority ?? defaultOptions.autoDialPriority
70
+ });
71
+ // check the min connection limit whenever a peer disconnects
72
+ this.addEventListener('peer:disconnect', () => {
73
+ this.autoDial.autoDial()
74
+ .catch(err => {
75
+ log.error(err);
76
+ });
77
+ });
78
+ // controls what happens when we have too many connections
79
+ this.connectionPruner = new ConnectionPruner({
80
+ connectionManager: this,
81
+ peerStore: components.peerStore
82
+ }, {
83
+ maxConnections: this.maxConnections,
84
+ allow: this.allow
85
+ });
86
+ // check the max connection limit whenever a peer connects
87
+ this.addEventListener('peer:connect', () => {
88
+ this.connectionPruner.maybePruneConnections()
89
+ .catch(err => {
90
+ log.error(err);
91
+ });
92
+ });
93
+ this.dialQueue = new DialQueue({
94
+ peerId: components.peerId,
95
+ metrics: components.metrics,
96
+ peerStore: components.peerStore,
97
+ transportManager: components.transportManager,
98
+ connectionGater: components.connectionGater
99
+ }, {
100
+ addressSorter: init.addressSorter ?? publicAddressesFirst,
101
+ maxParallelDials: init.maxParallelDials ?? MAX_PARALLEL_DIALS,
102
+ maxPeerAddrsToDial: init.maxPeerAddrsToDial ?? MAX_PEER_ADDRS_TO_DIAL,
103
+ dialTimeout: init.dialTimeout ?? DIAL_TIMEOUT,
104
+ resolvers: init.resolvers ?? {
105
+ dnsaddr: dnsaddrResolver
106
+ }
107
+ });
108
+ components.upgrader.addEventListener('connection', this.onConnect);
109
+ components.upgrader.addEventListener('connectionEnd', this.onDisconnect);
66
110
  }
67
111
  isStarted() {
68
112
  return this.started;
@@ -73,7 +117,7 @@ export class DefaultConnectionManager extends EventEmitter {
73
117
  */
74
118
  async start() {
75
119
  // track inbound/outbound connections
76
- this.components.metrics?.registerMetricGroup('libp2p_connection_manager_connections', {
120
+ this.metrics?.registerMetricGroup('libp2p_connection_manager_connections', {
77
121
  calculate: () => {
78
122
  const metric = {
79
123
  inbound: 0,
@@ -93,7 +137,7 @@ export class DefaultConnectionManager extends EventEmitter {
93
137
  }
94
138
  });
95
139
  // track total number of streams per protocol
96
- this.components.metrics?.registerMetricGroup('libp2p_protocol_streams_total', {
140
+ this.metrics?.registerMetricGroup('libp2p_protocol_streams_total', {
97
141
  label: 'protocol',
98
142
  calculate: () => {
99
143
  const metric = {};
@@ -109,7 +153,7 @@ export class DefaultConnectionManager extends EventEmitter {
109
153
  }
110
154
  });
111
155
  // track 90th percentile of streams per protocol
112
- this.components.metrics?.registerMetricGroup('libp2p_connection_manager_protocol_streams_per_connection_90th_percentile', {
156
+ this.metrics?.registerMetricGroup('libp2p_connection_manager_protocol_streams_per_connection_90th_percentile', {
113
157
  label: 'protocol',
114
158
  calculate: () => {
115
159
  const allStreams = {};
@@ -135,38 +179,24 @@ export class DefaultConnectionManager extends EventEmitter {
135
179
  return metric;
136
180
  }
137
181
  });
138
- // latency monitor
139
- this.latencyMonitor?.start();
140
- this._onLatencyMeasure = this._onLatencyMeasure.bind(this);
141
- this.latencyMonitor?.addEventListener('data', this._onLatencyMeasure);
182
+ this.autoDial.start();
142
183
  this.started = true;
143
184
  log('started');
144
185
  }
145
186
  async afterStart() {
146
- this.components.upgrader.addEventListener('connection', this.onConnect);
147
- this.components.upgrader.addEventListener('connectionEnd', this.onDisconnect);
148
187
  // re-connect to any peers with the KEEP_ALIVE tag
149
188
  void Promise.resolve()
150
189
  .then(async () => {
151
190
  const keepAlivePeers = [];
152
- for (const peer of await this.components.peerStore.all()) {
153
- const tags = await this.components.peerStore.getTags(peer.id);
191
+ for (const peer of await this.peerStore.all()) {
192
+ const tags = await this.peerStore.getTags(peer.id);
154
193
  const hasKeepAlive = tags.filter(tag => tag.name === KEEP_ALIVE).length > 0;
155
194
  if (hasKeepAlive) {
156
195
  keepAlivePeers.push(peer.id);
157
196
  }
158
197
  }
159
- this.connectOnStartupController?.clear();
160
- this.connectOnStartupController = new TimeoutController(this.startupReconnectTimeout);
161
- try {
162
- // fails on node < 15.4
163
- setMaxListeners?.(Infinity, this.connectOnStartupController.signal);
164
- }
165
- catch { }
166
198
  await Promise.all(keepAlivePeers.map(async (peer) => {
167
- await this.openConnection(peer, {
168
- signal: this.connectOnStartupController?.signal
169
- })
199
+ await this.openConnection(peer)
170
200
  .catch(err => {
171
201
  log.error(err);
172
202
  });
@@ -174,31 +204,15 @@ export class DefaultConnectionManager extends EventEmitter {
174
204
  })
175
205
  .catch(err => {
176
206
  log.error(err);
177
- })
178
- .finally(() => {
179
- this.connectOnStartupController?.clear();
180
207
  });
181
- }
182
- async beforeStop() {
183
- // if we are still dialing KEEP_ALIVE peers, abort those dials
184
- this.connectOnStartupController?.abort();
185
- this.components.upgrader.removeEventListener('connection', this.onConnect);
186
- this.components.upgrader.removeEventListener('connectionEnd', this.onDisconnect);
208
+ this.autoDial.afterStart();
187
209
  }
188
210
  /**
189
211
  * Stops the Connection Manager
190
212
  */
191
213
  async stop() {
192
- this.latencyMonitor?.removeEventListener('data', this._onLatencyMeasure);
193
- this.latencyMonitor?.stop();
194
- this.started = false;
195
- await this._close();
196
- log('stopped');
197
- }
198
- /**
199
- * Cleans up the connections
200
- */
201
- async _close() {
214
+ this.dialQueue.stop();
215
+ this.autoDial.stop();
202
216
  // Close all connections we're tracking
203
217
  const tasks = [];
204
218
  for (const connectionList of this.connections.values()) {
@@ -216,6 +230,7 @@ export class DefaultConnectionManager extends EventEmitter {
216
230
  log('closing %d connections', tasks.length);
217
231
  await Promise.all(tasks);
218
232
  this.connections.clear();
233
+ log('stopped');
219
234
  }
220
235
  onConnect(evt) {
221
236
  void this._onConnect(evt).catch(err => {
@@ -233,20 +248,16 @@ export class DefaultConnectionManager extends EventEmitter {
233
248
  return;
234
249
  }
235
250
  const peerId = connection.remotePeer;
236
- const peerIdStr = peerId.toString();
237
- const storedConns = this.connections.get(peerIdStr);
251
+ const storedConns = this.connections.get(peerId);
238
252
  if (storedConns != null) {
239
253
  storedConns.push(connection);
240
254
  }
241
255
  else {
242
- this.connections.set(peerIdStr, [connection]);
256
+ this.connections.set(peerId, [connection]);
243
257
  }
244
258
  if (peerId.publicKey != null) {
245
- await this.components.peerStore.keyBook.set(peerId, peerId.publicKey);
259
+ await this.peerStore.keyBook.set(peerId, peerId.publicKey);
246
260
  }
247
- const numConnections = this.getConnections().length;
248
- const toPrune = numConnections - this.opts.maxConnections;
249
- await this._checkMaxLimit('maxConnections', numConnections, toPrune);
250
261
  this.dispatchEvent(new CustomEvent('peer:connect', { detail: connection }));
251
262
  }
252
263
  /**
@@ -258,7 +269,7 @@ export class DefaultConnectionManager extends EventEmitter {
258
269
  // This can happen when we are in the process of shutting down the node
259
270
  return;
260
271
  }
261
- const peerId = connection.remotePeer.toString();
272
+ const peerId = connection.remotePeer;
262
273
  let storedConn = this.connections.get(peerId);
263
274
  if (storedConn != null && storedConn.length > 1) {
264
275
  storedConn = storedConn.filter((conn) => conn.id !== connection.id);
@@ -271,7 +282,7 @@ export class DefaultConnectionManager extends EventEmitter {
271
282
  }
272
283
  getConnections(peerId) {
273
284
  if (peerId != null) {
274
- return this.connections.get(peerId.toString()) ?? [];
285
+ return this.connections.get(peerId) ?? [];
275
286
  }
276
287
  let conns = [];
277
288
  for (const c of this.connections.values()) {
@@ -283,171 +294,44 @@ export class DefaultConnectionManager extends EventEmitter {
283
294
  return this.connections;
284
295
  }
285
296
  async openConnection(peerIdOrMultiaddr, options = {}) {
286
- const { peerId, multiaddr } = getPeerAddress(peerIdOrMultiaddr);
287
- if (peerId == null && multiaddr == null) {
288
- throw new CodeError('Can only open connections to PeerIds or Multiaddrs', codes.ERR_INVALID_PARAMETERS);
289
- }
297
+ const { peerId } = getPeerAddress(peerIdOrMultiaddr);
290
298
  if (peerId != null) {
291
- log('dial to', peerId);
299
+ log('dial %p', peerId);
292
300
  const existingConnections = this.getConnections(peerId);
293
301
  if (existingConnections.length > 0) {
294
302
  log('had an existing connection to %p', peerId);
295
303
  return existingConnections[0];
296
304
  }
297
305
  }
298
- let timeoutController;
299
- if (options?.signal == null) {
300
- timeoutController = new TimeoutController(this.dialTimeout);
301
- options.signal = timeoutController.signal;
302
- try {
303
- // fails on node < 15.4
304
- setMaxListeners?.(Infinity, timeoutController.signal);
305
- }
306
- catch { }
306
+ const connection = await this.dialQueue.dial(peerIdOrMultiaddr, {
307
+ ...options,
308
+ priority: options.priority ?? DEFAULT_DIAL_PRIORITY
309
+ });
310
+ let peerConnections = this.connections.get(connection.remotePeer);
311
+ if (peerConnections == null) {
312
+ peerConnections = [];
313
+ this.connections.set(connection.remotePeer, peerConnections);
307
314
  }
308
- try {
309
- const connection = await this.components.dialer.dial(peerIdOrMultiaddr, options);
310
- let peerConnections = this.connections.get(connection.remotePeer.toString());
311
- if (peerConnections == null) {
312
- peerConnections = [];
313
- this.connections.set(connection.remotePeer.toString(), peerConnections);
315
+ // we get notified of connections via the Upgrader emitting "connection"
316
+ // events, double check we aren't already tracking this connection before
317
+ // storing it
318
+ let trackedConnection = false;
319
+ for (const conn of peerConnections) {
320
+ if (conn.id === connection.id) {
321
+ trackedConnection = true;
314
322
  }
315
- // we get notified of connections via the Upgrader emitting "connection"
316
- // events, double check we aren't already tracking this connection before
317
- // storing it
318
- let trackedConnection = false;
319
- for (const conn of peerConnections) {
320
- if (conn.id === connection.id) {
321
- trackedConnection = true;
322
- }
323
- }
324
- if (!trackedConnection) {
325
- peerConnections.push(connection);
326
- }
327
- return connection;
328
323
  }
329
- finally {
330
- if (timeoutController != null) {
331
- timeoutController.clear();
332
- }
324
+ if (!trackedConnection) {
325
+ peerConnections.push(connection);
333
326
  }
327
+ return connection;
334
328
  }
335
329
  async closeConnections(peerId) {
336
- const connections = this.connections.get(peerId.toString()) ?? [];
330
+ const connections = this.connections.get(peerId) ?? [];
337
331
  await Promise.all(connections.map(async (connection) => {
338
332
  await connection.close();
339
333
  }));
340
334
  }
341
- /**
342
- * Get all open connections with a peer
343
- */
344
- getAll(peerId) {
345
- if (!isPeerId(peerId)) {
346
- throw new CodeError('peerId must be an instance of peer-id', codes.ERR_INVALID_PARAMETERS);
347
- }
348
- const id = peerId.toString();
349
- const connections = this.connections.get(id);
350
- // Return all open connections
351
- if (connections != null) {
352
- return connections.filter(connection => connection.stat.status === STATUS.OPEN);
353
- }
354
- return [];
355
- }
356
- /**
357
- * If the event loop is slow, maybe close a connection
358
- */
359
- _onLatencyMeasure(evt) {
360
- const { detail: summary } = evt;
361
- this._checkMaxLimit('maxEventLoopDelay', summary.avgMs, 1)
362
- .catch(err => {
363
- log.error(err);
364
- });
365
- }
366
- /**
367
- * If the `value` of `name` has exceeded its limit, maybe close a connection
368
- */
369
- async _checkMaxLimit(name, value, toPrune = 1) {
370
- const limit = this.opts[name];
371
- if (limit == null) {
372
- log.trace('limit %s was not set so it cannot be applied', name);
373
- return;
374
- }
375
- log.trace('checking limit of %s. current value: %d of %d', name, value, limit);
376
- if (value > limit) {
377
- log('%s: limit exceeded: %p, %d/%d, pruning %d connection(s)', this.components.peerId, name, value, limit, toPrune);
378
- await this._pruneConnections(toPrune);
379
- }
380
- }
381
- /**
382
- * If we have more connections than our maximum, select some excess connections
383
- * to prune based on peer value
384
- */
385
- async _pruneConnections(toPrune) {
386
- const connections = this.getConnections();
387
- const peerValues = new PeerMap();
388
- // work out peer values
389
- for (const connection of connections) {
390
- const remotePeer = connection.remotePeer;
391
- if (peerValues.has(remotePeer)) {
392
- continue;
393
- }
394
- const tags = await this.components.peerStore.getTags(remotePeer);
395
- // sum all tag values
396
- peerValues.set(remotePeer, tags.reduce((acc, curr) => {
397
- return acc + curr.value;
398
- }, 0));
399
- }
400
- // sort by value, lowest to highest
401
- const sortedConnections = connections.sort((a, b) => {
402
- const peerAValue = peerValues.get(a.remotePeer) ?? 0;
403
- const peerBValue = peerValues.get(b.remotePeer) ?? 0;
404
- if (peerAValue > peerBValue) {
405
- return 1;
406
- }
407
- if (peerAValue < peerBValue) {
408
- return -1;
409
- }
410
- // if the peers have an equal tag value then we want to close short-lived connections first
411
- const connectionALifespan = a.stat.timeline.open;
412
- const connectionBLifespan = b.stat.timeline.open;
413
- if (connectionALifespan < connectionBLifespan) {
414
- return 1;
415
- }
416
- if (connectionALifespan > connectionBLifespan) {
417
- return -1;
418
- }
419
- return 0;
420
- });
421
- // close some connections
422
- const toClose = [];
423
- for (const connection of sortedConnections) {
424
- log('too many connections open - closing a connection to %p', connection.remotePeer);
425
- // check allow list
426
- const connectionInAllowList = this.allow.some((ma) => {
427
- return connection.remoteAddr.toString().startsWith(ma.toString());
428
- });
429
- // Connections in the allow list should be excluded from pruning
430
- if (!connectionInAllowList) {
431
- toClose.push(connection);
432
- }
433
- if (toClose.length === toPrune) {
434
- break;
435
- }
436
- }
437
- // close connections
438
- await Promise.all(toClose.map(async (connection) => {
439
- try {
440
- await connection.close();
441
- }
442
- catch (err) {
443
- log.error(err);
444
- }
445
- // TODO: should not need to invoke this manually
446
- this.onDisconnect(new CustomEvent('connectionEnd', {
447
- detail: connection
448
- }));
449
- }));
450
- }
451
335
  async acceptIncomingConnection(maConn) {
452
336
  // check deny list
453
337
  const denyConnection = this.deny.some(ma => {
@@ -466,7 +350,7 @@ export class DefaultConnectionManager extends EventEmitter {
466
350
  return true;
467
351
  }
468
352
  // check pending connections
469
- if (this.incomingPendingConnections === this.opts.maxIncomingPendingConnections) {
353
+ if (this.incomingPendingConnections === this.maxIncomingPendingConnections) {
470
354
  log('connection from %s refused - incomingPendingConnections exceeded by peer %s', maConn.remoteAddr);
471
355
  return false;
472
356
  }
@@ -480,7 +364,7 @@ export class DefaultConnectionManager extends EventEmitter {
480
364
  return false;
481
365
  }
482
366
  }
483
- if (this.getConnections().length < this.opts.maxConnections) {
367
+ if (this.getConnections().length < this.maxConnections) {
484
368
  this.incomingPendingConnections++;
485
369
  return true;
486
370
  }
@@ -490,5 +374,8 @@ export class DefaultConnectionManager extends EventEmitter {
490
374
  afterUpgradeInbound() {
491
375
  this.incomingPendingConnections--;
492
376
  }
377
+ getDialQueue() {
378
+ return this.dialQueue.pendingDials;
379
+ }
493
380
  }
494
381
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/connection-manager/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,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} from '@multiformats/multiaddr';
2
+ import type { Multiaddr } from '@multiformats/multiaddr';
3
+ import { ClearableSignal } from 'any-signal';
4
+ /**
5
+ * Resolve multiaddr recursively
6
+ */
7
+ export declare function resolveMultiaddrs(ma: Multiaddr, options: AbortOptions): Promise<Multiaddr[]>;
8
+ export declare function combineSignals(...signals: Array<AbortSignal | undefined>): ClearableSignal;
9
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/connection-manager/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAa,MAAM,yBAAyB,CAAA;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAExD,OAAO,EAAE,eAAe,EAAa,MAAM,YAAY,CAAA;AAKvD;;GAEG;AACH,wBAAsB,iBAAiB,CAAE,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,CA0BnG;AAgBD,wBAAgB,cAAc,CAAE,GAAG,OAAO,EAAE,KAAK,CAAC,WAAW,GAAG,SAAS,CAAC,GAAG,eAAe,CAsB3F"}
@@ -0,0 +1,66 @@
1
+ import { multiaddr } from '@multiformats/multiaddr';
2
+ import { logger } from '@libp2p/logger';
3
+ import { anySignal } from 'any-signal';
4
+ import { setMaxListeners } from 'events';
5
+ const log = logger('libp2p:connection-manager:utils');
6
+ /**
7
+ * Resolve multiaddr recursively
8
+ */
9
+ export async function resolveMultiaddrs(ma, options) {
10
+ // TODO: recursive logic should live in multiaddr once dns4/dns6 support is in place
11
+ // Now only supporting resolve for dnsaddr
12
+ const resolvableProto = ma.protoNames().includes('dnsaddr');
13
+ // Multiaddr is not resolvable? End recursion!
14
+ if (!resolvableProto) {
15
+ return [ma];
16
+ }
17
+ const resolvedMultiaddrs = await resolveRecord(ma, options);
18
+ const recursiveMultiaddrs = await Promise.all(resolvedMultiaddrs.map(async (nm) => {
19
+ return await resolveMultiaddrs(nm, options);
20
+ }));
21
+ const addrs = recursiveMultiaddrs.flat();
22
+ const output = addrs.reduce((array, newM) => {
23
+ if (array.find(m => m.equals(newM)) == null) {
24
+ array.push(newM);
25
+ }
26
+ return array;
27
+ }, ([]));
28
+ log('resolved %s to', ma, output.map(ma => ma.toString()));
29
+ return output;
30
+ }
31
+ /**
32
+ * Resolve a given multiaddr. If this fails, an empty array will be returned
33
+ */
34
+ async function resolveRecord(ma, options) {
35
+ try {
36
+ ma = multiaddr(ma.toString()); // Use current multiaddr module
37
+ const multiaddrs = await ma.resolve(options);
38
+ return multiaddrs;
39
+ }
40
+ catch (err) {
41
+ log.error(`multiaddr ${ma.toString()} could not be resolved`, err);
42
+ return [];
43
+ }
44
+ }
45
+ export function combineSignals(...signals) {
46
+ const sigs = [];
47
+ for (const sig of signals) {
48
+ if (sig != null) {
49
+ try {
50
+ // fails on node < 15.4
51
+ setMaxListeners?.(Infinity, sig);
52
+ }
53
+ catch { }
54
+ sigs.push(sig);
55
+ }
56
+ }
57
+ // let any signal abort the dial
58
+ const signal = anySignal(sigs);
59
+ try {
60
+ // fails on node < 15.4
61
+ setMaxListeners?.(Infinity, signal);
62
+ }
63
+ catch { }
64
+ return signal;
65
+ }
66
+ //# sourceMappingURL=utils.js.map