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
@@ -0,0 +1,366 @@
1
+ import { logger } from '@libp2p/logger';
2
+ import { AbortError, CodeError } from '@libp2p/interfaces/errors';
3
+ import { resolvers } from '@multiformats/multiaddr';
4
+ import { TimeoutController } from 'timeout-abort-controller';
5
+ import { publicAddressesFirst } from '@libp2p/utils/address-sort';
6
+ import { codes } from '../errors.js';
7
+ import { DIAL_TIMEOUT, MAX_PARALLEL_DIALS_PER_PEER, MAX_PARALLEL_DIALS, MAX_PEER_ADDRS_TO_DIAL } from './constants.js';
8
+ import { getPeerAddress } from '../get-peer.js';
9
+ import PQueue from 'p-queue';
10
+ import { dnsaddrResolver } from '@multiformats/multiaddr/resolvers';
11
+ import { combineSignals, resolveMultiaddrs } from './utils.js';
12
+ import pDefer from 'p-defer';
13
+ const log = logger('libp2p:connection-manager:dial-queue');
14
+ const defaultOptions = {
15
+ addressSorter: publicAddressesFirst,
16
+ maxParallelDials: MAX_PARALLEL_DIALS,
17
+ maxPeerAddrsToDial: MAX_PEER_ADDRS_TO_DIAL,
18
+ maxParallelDialsPerPeer: MAX_PARALLEL_DIALS_PER_PEER,
19
+ dialTimeout: DIAL_TIMEOUT,
20
+ resolvers: {
21
+ dnsaddr: dnsaddrResolver
22
+ }
23
+ };
24
+ export class DialQueue {
25
+ constructor(components, init = {}) {
26
+ this.addressSorter = init.addressSorter ?? defaultOptions.addressSorter;
27
+ this.maxPeerAddrsToDial = init.maxPeerAddrsToDial ?? defaultOptions.maxPeerAddrsToDial;
28
+ this.maxParallelDialsPerPeer = init.maxParallelDialsPerPeer ?? defaultOptions.maxParallelDialsPerPeer;
29
+ this.dialTimeout = init.dialTimeout ?? defaultOptions.dialTimeout;
30
+ this.peerId = components.peerId;
31
+ this.peerStore = components.peerStore;
32
+ this.connectionGater = components.connectionGater;
33
+ this.transportManager = components.transportManager;
34
+ this.shutDownController = new AbortController();
35
+ this.pendingDialCount = components.metrics?.registerMetric('libp2p_dialler_pending_dials');
36
+ this.inProgressDialCount = components.metrics?.registerMetric('libp2p_dialler_in_progress_dials');
37
+ this.pendingDials = [];
38
+ for (const [key, value] of Object.entries(init.resolvers ?? {})) {
39
+ resolvers.set(key, value);
40
+ }
41
+ // controls dial concurrency
42
+ this.queue = new PQueue({
43
+ concurrency: init.maxParallelDials ?? defaultOptions.maxParallelDials
44
+ });
45
+ // a job was added to the queue
46
+ this.queue.on('add', () => {
47
+ this.pendingDialCount?.update(this.queue.size);
48
+ this.inProgressDialCount?.update(this.queue.pending);
49
+ });
50
+ // a queued job started
51
+ this.queue.on('active', () => {
52
+ this.pendingDialCount?.update(this.queue.size);
53
+ this.inProgressDialCount?.update(this.queue.pending);
54
+ });
55
+ // a started job completed without error
56
+ this.queue.on('completed', () => {
57
+ this.pendingDialCount?.update(this.queue.size);
58
+ this.inProgressDialCount?.update(this.queue.pending);
59
+ });
60
+ // a started job errored
61
+ this.queue.on('error', (err) => {
62
+ log.error('error in dial queue', err);
63
+ this.pendingDialCount?.update(this.queue.size);
64
+ this.inProgressDialCount?.update(this.queue.pending);
65
+ });
66
+ // all queued jobs have been started
67
+ this.queue.on('empty', () => {
68
+ this.pendingDialCount?.update(this.queue.size);
69
+ this.inProgressDialCount?.update(this.queue.pending);
70
+ });
71
+ // add started jobs have run and the queue is empty
72
+ this.queue.on('idle', () => {
73
+ this.pendingDialCount?.update(this.queue.size);
74
+ this.inProgressDialCount?.update(this.queue.pending);
75
+ });
76
+ }
77
+ /**
78
+ * Clears any pending dials
79
+ */
80
+ stop() {
81
+ this.shutDownController.abort();
82
+ }
83
+ /**
84
+ * Connects to a given peer, multiaddr or list of multiaddrs.
85
+ *
86
+ * If a peer is passed, all known multiaddrs will be tried. If a multiaddr or
87
+ * multiaddrs are passed only those will be dialled.
88
+ *
89
+ * Where a list of multiaddrs is passed, if any contain a peer id then all
90
+ * multiaddrs in the list must contain the same peer id.
91
+ *
92
+ * The dial to the first address that is successfully able to upgrade a connection
93
+ * will be used, all other dials will be aborted when that happens.
94
+ */
95
+ async dial(peerIdOrMultiaddr, options = {}) {
96
+ const { peerId, multiaddrs } = getPeerAddress(peerIdOrMultiaddr);
97
+ const addrs = multiaddrs.map(multiaddr => ({
98
+ multiaddr,
99
+ isCertified: false
100
+ }));
101
+ // create abort conditions - need to do this before `calculateMultiaddrs` as we may be about to
102
+ // resolve a dns addr which can time out
103
+ const { timeoutController, signal } = this.createDialAbortControllers(options.signal);
104
+ let addrsToDial;
105
+ try {
106
+ // load addresses from address book, resolve and dnsaddrs, filter undiallables, add peer IDs, etc
107
+ addrsToDial = await this.calculateMultiaddrs(peerId, addrs, {
108
+ ...options,
109
+ signal
110
+ });
111
+ }
112
+ catch (err) {
113
+ signal.clear();
114
+ timeoutController.clear();
115
+ throw err;
116
+ }
117
+ // ready to dial, all async work finished - make sure we don't have any
118
+ // pending dials in progress for this peer or set of multiaddrs
119
+ const existingDial = this.pendingDials.find(dial => {
120
+ // is the dial for the same peer id?
121
+ if (dial.peerId != null && peerId != null && dial.peerId.equals(peerId)) {
122
+ return true;
123
+ }
124
+ // is the dial for the same set of multiaddrs?
125
+ if (addrsToDial.map(({ multiaddr }) => multiaddr.toString()).join() === dial.multiaddrs.map(multiaddr => multiaddr.toString()).join()) {
126
+ return true;
127
+ }
128
+ return false;
129
+ });
130
+ if (existingDial != null) {
131
+ log('joining existing dial target for %p', peerId);
132
+ signal.clear();
133
+ timeoutController.clear();
134
+ return await existingDial.promise;
135
+ }
136
+ log('creating dial target for', addrsToDial.map(({ multiaddr }) => multiaddr.toString()));
137
+ // @ts-expect-error .promise property is set below
138
+ const pendingDial = {
139
+ id: randomId(),
140
+ status: 'queued',
141
+ peerId,
142
+ multiaddrs: addrsToDial.map(({ multiaddr }) => multiaddr)
143
+ };
144
+ pendingDial.promise = this.performDial(pendingDial, {
145
+ ...options,
146
+ signal
147
+ })
148
+ .finally(() => {
149
+ // remove our pending dial entry
150
+ this.pendingDials = this.pendingDials.filter(p => p.id !== pendingDial.id);
151
+ // clean up abort signals/controllers
152
+ signal.clear();
153
+ timeoutController.clear();
154
+ })
155
+ .catch(err => {
156
+ log.error('dial failed to %s', addrsToDial.map(({ multiaddr }) => multiaddr.toString()).join(', '), err);
157
+ // Error is a timeout
158
+ if (timeoutController.signal.aborted) {
159
+ const error = new CodeError(err.message, codes.ERR_TIMEOUT);
160
+ throw error;
161
+ }
162
+ throw err;
163
+ });
164
+ // let other dials join this one
165
+ this.pendingDials.push(pendingDial);
166
+ return await pendingDial.promise;
167
+ }
168
+ createDialAbortControllers(userSignal) {
169
+ // ensure we throw if the dial takes longer than the dial timeout
170
+ const timeoutController = new TimeoutController(this.dialTimeout);
171
+ // let any signal abort the dial
172
+ const signal = combineSignals(timeoutController.signal, this.shutDownController.signal, userSignal);
173
+ return { timeoutController, signal };
174
+ }
175
+ async calculateMultiaddrs(peerId, addrs = [], options = {}) {
176
+ // if a peer id or multiaddr(s) with a peer id, make sure it isn't our peer id and that we are allowed to dial it
177
+ if (peerId != null) {
178
+ if (this.peerId.equals(peerId)) {
179
+ throw new CodeError('Tried to dial self', codes.ERR_DIALED_SELF);
180
+ }
181
+ if ((await this.connectionGater.denyDialPeer?.(peerId)) === true) {
182
+ throw new CodeError('The dial request is blocked by gater.allowDialPeer', codes.ERR_PEER_DIAL_INTERCEPTED);
183
+ }
184
+ // if just a peer id was passed, load available multiaddrs for this peer from the address book
185
+ if (addrs.length === 0) {
186
+ log('loading multiaddrs for %p', peerId);
187
+ addrs.push(...(await this.peerStore.addressBook.get(peerId)));
188
+ log('loaded multiaddrs for %p', peerId, addrs.map(({ multiaddr }) => multiaddr.toString()));
189
+ }
190
+ }
191
+ // resolve addresses - this can result in a one-to-many translation when dnsaddrs are resolved
192
+ const resolvedAddresses = (await Promise.all(addrs.map(async (addr) => {
193
+ const result = await resolveMultiaddrs(addr.multiaddr, options);
194
+ if (result.length === 1 && result[0].equals(addr.multiaddr)) {
195
+ return addr;
196
+ }
197
+ return result.map(multiaddr => ({
198
+ multiaddr,
199
+ isCertified: false
200
+ }));
201
+ })))
202
+ .flat();
203
+ // filter out any multiaddrs that we do not have transports for
204
+ const filteredAddrs = resolvedAddresses.filter(addr => Boolean(this.transportManager.transportForMultiaddr(addr.multiaddr)));
205
+ // deduplicate addresses
206
+ const dedupedAddrs = new Map();
207
+ for (const addr of filteredAddrs) {
208
+ const maStr = addr.multiaddr.toString();
209
+ const existing = dedupedAddrs.get(maStr);
210
+ if (existing != null) {
211
+ existing.isCertified = existing.isCertified || addr.isCertified || false;
212
+ continue;
213
+ }
214
+ dedupedAddrs.set(maStr, addr);
215
+ }
216
+ let dedupedMultiaddrs = [...dedupedAddrs.values()];
217
+ if (dedupedMultiaddrs.length === 0 || dedupedMultiaddrs.length > this.maxPeerAddrsToDial) {
218
+ log('addresses for %p before filtering', peerId ?? 'unknown peer', resolvedAddresses.map(({ multiaddr }) => multiaddr.toString()));
219
+ log('addresses for %p after filtering', peerId ?? 'unknown peer', dedupedMultiaddrs.map(({ multiaddr }) => multiaddr.toString()));
220
+ }
221
+ // make sure we actually have some addresses to dial
222
+ if (dedupedMultiaddrs.length === 0) {
223
+ throw new CodeError('The dial request has no valid addresses', codes.ERR_NO_VALID_ADDRESSES);
224
+ }
225
+ // make sure we don't have too many addresses to dial
226
+ if (dedupedMultiaddrs.length > this.maxPeerAddrsToDial) {
227
+ throw new CodeError('dial with more addresses than allowed', codes.ERR_TOO_MANY_ADDRESSES);
228
+ }
229
+ // append peer id to multiaddrs if it is not already present
230
+ if (peerId != null) {
231
+ const peerIdMultiaddr = `/p2p/${peerId.toString()}`;
232
+ dedupedMultiaddrs = dedupedMultiaddrs.map(addr => {
233
+ const addressPeerId = addr.multiaddr.getPeerId();
234
+ const lastProto = addr.multiaddr.protos().pop();
235
+ // do not append peer id to path multiaddrs
236
+ if (lastProto?.path === true) {
237
+ return addr;
238
+ }
239
+ if (addressPeerId == null) {
240
+ return {
241
+ multiaddr: addr.multiaddr.encapsulate(peerIdMultiaddr),
242
+ isCertified: addr.isCertified
243
+ };
244
+ }
245
+ return addr;
246
+ });
247
+ }
248
+ const gatedAdrs = [];
249
+ for (const addr of dedupedMultiaddrs) {
250
+ // @ts-expect-error needs updating in the interface
251
+ if (this.connectionGater.denyDialMultiaddr != null && await this.connectionGater.denyDialMultiaddr(addr.multiaddr)) {
252
+ continue;
253
+ }
254
+ gatedAdrs.push(addr);
255
+ }
256
+ return gatedAdrs.sort(this.addressSorter);
257
+ }
258
+ async performDial(pendingDial, options = {}) {
259
+ const dialAbortControllers = pendingDial.multiaddrs.map(() => new AbortController());
260
+ try {
261
+ // internal peer dial queue to ensure we only dial the configured number of addresses
262
+ // per peer at the same time to prevent one peer with a lot of addresses swamping
263
+ // the dial queue
264
+ const peerDialQueue = new PQueue({
265
+ concurrency: this.maxParallelDialsPerPeer
266
+ });
267
+ peerDialQueue.on('error', (err) => {
268
+ log.error('error dialling', err);
269
+ });
270
+ const conn = await Promise.any(pendingDial.multiaddrs.map(async (addr, i) => {
271
+ const controller = dialAbortControllers[i];
272
+ if (controller == null) {
273
+ throw new CodeError('dialAction did not come with an AbortController', codes.ERR_INVALID_PARAMETERS);
274
+ }
275
+ // let any signal abort the dial
276
+ const signal = combineSignals(controller.signal, options.signal);
277
+ signal.addEventListener('abort', () => {
278
+ log('dial to %s aborted', addr);
279
+ });
280
+ const deferred = pDefer();
281
+ await peerDialQueue.add(async () => {
282
+ if (signal.aborted) {
283
+ log('dial to %s was aborted before reaching the head of the peer dial queue', addr);
284
+ deferred.reject(new AbortError());
285
+ return;
286
+ }
287
+ // add the individual dial to the dial queue so we don't breach maxConcurrentDials
288
+ await this.queue.add(async () => {
289
+ try {
290
+ if (signal.aborted) {
291
+ log('dial to %s was aborted before reaching the head of the dial queue', addr);
292
+ deferred.reject(new AbortError());
293
+ return;
294
+ }
295
+ // update dial status
296
+ pendingDial.status = 'active';
297
+ const conn = await this.transportManager.dial(addr, {
298
+ ...options,
299
+ signal
300
+ });
301
+ if (controller.signal.aborted) {
302
+ // another dial succeeded faster than this one
303
+ log('multiple dials succeeded, closing superfluous connection');
304
+ conn.close().catch(err => {
305
+ log.error('error closing superfluous connection', err);
306
+ });
307
+ deferred.reject(new AbortError());
308
+ return;
309
+ }
310
+ // remove the successful AbortController so it is not aborted
311
+ dialAbortControllers[i] = undefined;
312
+ // immediately abort any other dials
313
+ dialAbortControllers.forEach(c => {
314
+ if (c !== undefined) {
315
+ c.abort();
316
+ }
317
+ });
318
+ log('dial to %s succeeded', addr);
319
+ // resolve the connection promise
320
+ deferred.resolve(conn);
321
+ }
322
+ catch (err) {
323
+ // something only went wrong if our signal was not aborted
324
+ log.error('error during dial of %s', addr, err);
325
+ deferred.reject(err);
326
+ }
327
+ }, {
328
+ ...options,
329
+ signal
330
+ }).catch(err => {
331
+ deferred.reject(err);
332
+ });
333
+ }, {
334
+ signal
335
+ }).catch(err => {
336
+ deferred.reject(err);
337
+ }).finally(() => {
338
+ signal.clear();
339
+ });
340
+ return await deferred.promise;
341
+ }));
342
+ // dial succeeded or failed
343
+ if (conn == null) {
344
+ throw new CodeError('successful dial led to empty object returned from peer dial queue', codes.ERR_TRANSPORT_DIAL_FAILED);
345
+ }
346
+ pendingDial.status = 'success';
347
+ return conn;
348
+ }
349
+ catch (err) {
350
+ pendingDial.status = 'error';
351
+ // if we only dialled one address, unwrap the AggregateError to provide more
352
+ // useful feedback to the user
353
+ if (pendingDial.multiaddrs.length === 1 && err.name === 'AggregateError') {
354
+ throw err.errors[0];
355
+ }
356
+ throw err;
357
+ }
358
+ }
359
+ }
360
+ /**
361
+ * Returns a random string
362
+ */
363
+ function randomId() {
364
+ return `${(parseInt(String(Math.random() * 1e9), 10)).toString()}${Date.now()}`;
365
+ }
366
+ //# sourceMappingURL=dial-queue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dial-queue.js","sourceRoot":"","sources":["../../../src/connection-manager/dial-queue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AACjE,OAAO,EAAuB,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AACjE,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AACpC,OAAO,EACL,YAAY,EACZ,2BAA2B,EAC3B,kBAAkB,EAClB,sBAAsB,EACvB,MAAM,gBAAgB,CAAA;AAIvB,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAK/C,OAAO,MAAM,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM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A;gBACtB,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE;oBACd,MAAM,CAAC,KAAK,EAAE,CAAA;gBAChB,CAAC,CAAC,CAAA;gBAEF,OAAO,MAAM,QAAQ,CAAC,OAAO,CAAA;YAC/B,CAAC,CAAC,CAAC,CAAA;YAEH,2BAA2B;YAC3B,IAAI,IAAI,IAAI,IAAI,EAAE;gBAChB,MAAM,IAAI,SAAS,CAAC,mEAAmE,EAAE,KAAK,CAAC,yBAAyB,CAAC,CAAA;aAC1H;YAED,WAAW,CAAC,MAAM,GAAG,SAAS,CAAA;YAE9B,OAAO,IAAI,CAAA;SACZ;QAAC,OAAO,GAAQ,EAAE;YACjB,WAAW,CAAC,MAAM,GAAG,OAAO,CAAA;YAE5B,4EAA4E;YAC5E,8BAA8B;YAC9B,IAAI,WAAW,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,IAAI,GAAG,CAAC,IAAI,KAAK,gBAAgB,EAAE;gBACxE,MAAM,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;aACpB;YAED,MAAM,GAAG,CAAA;SACV;IACH,CAAC;CACF;AAED;;GAEG;AACH,SAAS,QAAQ;IACf,OAAO,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,EAAE,CAAA;AACjF,CAAC"}
@@ -1,48 +1,69 @@
1
- import { SummaryObject } from './latency-monitor.js';
2
1
  import type { AbortOptions } from '@libp2p/interfaces';
3
2
  import { EventEmitter } from '@libp2p/interfaces/events';
4
3
  import type { Startable } from '@libp2p/interfaces/startable';
5
- import { PeerId } from '@libp2p/interface-peer-id';
4
+ import type { PeerId } from '@libp2p/interface-peer-id';
6
5
  import type { Connection, MultiaddrConnection } from '@libp2p/interface-connection';
7
- import type { ConnectionManager, ConnectionManagerEvents, Dialer } from '@libp2p/interface-connection-manager';
6
+ import type { ConnectionManager, ConnectionManagerEvents } from '@libp2p/interface-connection-manager';
8
7
  import type { AddressSorter, PeerStore } from '@libp2p/interface-peer-store';
9
8
  import { Multiaddr, Resolver } from '@multiformats/multiaddr';
10
9
  import type { Metrics } from '@libp2p/interface-metrics';
11
- import type { Upgrader } from '@libp2p/interface-transport';
12
- export interface ConnectionManagerConfig {
10
+ import type { TransportManager, Upgrader } from '@libp2p/interface-transport';
11
+ import { AutoDial } from './auto-dial.js';
12
+ import { DialQueue } from './dial-queue.js';
13
+ import { ConnectionPruner } from './connection-pruner.js';
14
+ import type { ConnectionGater } from '@libp2p/interface-connection-gater';
15
+ import { PeerMap } from '@libp2p/peer-collections';
16
+ import type { PendingDial } from '../libp2p.js';
17
+ export interface ConnectionManagerInit {
13
18
  /**
14
- * The maximum number of connections libp2p is willing to have before it starts disconnecting. Defaults to `Infinity`
19
+ * The maximum number of connections libp2p is willing to have before it starts
20
+ * pruning connections to reduce resource usage. (default: 300)
15
21
  */
16
- maxConnections: number;
22
+ maxConnections?: number;
17
23
  /**
18
- * The minimum number of connections below which libp2p not activate preemptive disconnections. Defaults to `0`.
24
+ * The minimum number of connections below which libp2p will start to dial peers
25
+ * from the peer book. Setting this to 0 effectively disables this behaviour.
26
+ * (default: 50)
19
27
  */
20
- minConnections: number;
28
+ minConnections?: number;
21
29
  /**
22
- * Sets the maximum event loop delay (measured in milliseconds) this node is willing to endure before it starts disconnecting peers. Defaults to `Infinity`.
30
+ * How long to wait between attempting to keep our number of concurrent connections
31
+ * above minConnections (default: 5000)
23
32
  */
24
- maxEventLoopDelay?: number;
33
+ autoDialInterval?: number;
25
34
  /**
26
- * Sets the poll interval (in milliseconds) for assessing the current state and determining if this peer needs to force a disconnect. Defaults to `2000` (2 seconds).
35
+ * When dialling peers from the peer book to keep the number of open connections
36
+ * above `minConnections`, add dials for this many peers to the dial queue
37
+ * at once. (default: 25)
27
38
  */
28
- pollInterval?: number;
39
+ autoDialConcurrency?: number;
29
40
  /**
30
- * How long to wait between attempting to keep our number of concurrent connections
31
- * above minConnections
41
+ * To allow user dials to take priority over auto dials, use this value as the
42
+ * dial priority. (default: 0)
32
43
  */
33
- autoDialInterval: number;
44
+ autoDialPriority?: number;
34
45
  /**
35
- * Sort the known addresses of a peer before trying to dial
46
+ * Sort the known addresses of a peer before trying to dial, By default public
47
+ * addresses will be dialled before private (e.g. loopback or LAN) addresses.
36
48
  */
37
49
  addressSorter?: AddressSorter;
38
50
  /**
39
- * Number of max concurrent dials
51
+ * The maximum number of dials across all peers to execute in parallel.
52
+ * (default: 100)
40
53
  */
41
54
  maxParallelDials?: number;
42
55
  /**
43
- * Number of max addresses to dial for a given peer
56
+ * To prevent individual peers with large amounts of multiaddrs swamping the
57
+ * dial queue, this value controls how many addresses to dial in parallel per
58
+ * peer. So for example if two peers have 10 addresses and this value is set
59
+ * at 5, we will dial 5 addresses from each at a time. (default: 10)
60
+ */
61
+ maxParallelDialsPerPeer?: number;
62
+ /**
63
+ * Maximum number of addresses allowed for a given peer - if a peer has more
64
+ * addresses than this then the dial will fail. (default: 25)
44
65
  */
45
- maxAddrsToDial?: number;
66
+ maxPeerAddrsToDial?: number;
46
67
  /**
47
68
  * How long a dial attempt is allowed to take, including DNS resolution
48
69
  * of the multiaddr, opening a socket and upgrading it to a Connection.
@@ -50,22 +71,13 @@ export interface ConnectionManagerConfig {
50
71
  dialTimeout?: number;
51
72
  /**
52
73
  * When a new inbound connection is opened, the upgrade process (e.g. protect,
53
- * encrypt, multiplex etc) must complete within this number of ms.
54
- */
55
- inboundUpgradeTimeout: number;
56
- /**
57
- * Number of max concurrent dials per peer
74
+ * encrypt, multiplex etc) must complete within this number of ms. (default: 30s)
58
75
  */
59
- maxDialsPerPeer?: number;
76
+ inboundUpgradeTimeout?: number;
60
77
  /**
61
- * Multiaddr resolvers to use when dialing
78
+ * Multiaddr resolvers to use when dialling
62
79
  */
63
80
  resolvers?: Record<string, Resolver>;
64
- /**
65
- * On startup we try to dial any peer that has previously been
66
- * tagged with KEEP_ALIVE up to this timeout in ms. (default: 60000)
67
- */
68
- startupReconnectTimeout?: number;
69
81
  /**
70
82
  * A list of multiaddrs that will always be allowed (except if they are in the
71
83
  * deny list) to open connections to this node even if we've reached maxConnections
@@ -78,12 +90,13 @@ export interface ConnectionManagerConfig {
78
90
  deny?: string[];
79
91
  /**
80
92
  * If more than this many connections are opened per second by a single
81
- * host, reject subsequent connections
93
+ * host, reject subsequent connections. (default: 5)
82
94
  */
83
95
  inboundConnectionThreshold?: number;
84
96
  /**
85
97
  * The maximum number of parallel incoming connections allowed that have yet to
86
- * complete the connection upgrade - e.g. choosing connection encryption, muxer, etc
98
+ * complete the connection upgrade - e.g. choosing connection encryption, muxer, etc.
99
+ * (default: 10)
87
100
  */
88
101
  maxIncomingPendingConnections?: number;
89
102
  }
@@ -92,26 +105,30 @@ export interface DefaultConnectionManagerComponents {
92
105
  metrics?: Metrics;
93
106
  upgrader: Upgrader;
94
107
  peerStore: PeerStore;
95
- dialer: Dialer;
108
+ transportManager: TransportManager;
109
+ connectionGater: ConnectionGater;
110
+ }
111
+ export interface OpenConnectionOptions extends AbortOptions {
112
+ priority?: number;
96
113
  }
97
- export type ConnectionManagerInit = ConnectionManagerConfig;
98
114
  /**
99
115
  * Responsible for managing known connections.
100
116
  */
101
117
  export declare class DefaultConnectionManager extends EventEmitter<ConnectionManagerEvents> implements ConnectionManager, Startable {
102
- private readonly components;
103
- private readonly opts;
104
- private readonly connections;
105
118
  private started;
106
- private readonly latencyMonitor?;
107
- private readonly startupReconnectTimeout;
108
- private connectOnStartupController?;
109
- private readonly dialTimeout;
119
+ private readonly connections;
110
120
  private readonly allow;
111
121
  private readonly deny;
112
- private readonly inboundConnectionRateLimiter;
122
+ private readonly maxIncomingPendingConnections;
113
123
  private incomingPendingConnections;
114
- constructor(components: DefaultConnectionManagerComponents, init: ConnectionManagerConfig);
124
+ private readonly maxConnections;
125
+ readonly dialQueue: DialQueue;
126
+ readonly autoDial: AutoDial;
127
+ readonly connectionPruner: ConnectionPruner;
128
+ private readonly inboundConnectionRateLimiter;
129
+ private readonly peerStore;
130
+ private readonly metrics?;
131
+ constructor(components: DefaultConnectionManagerComponents, init?: ConnectionManagerInit);
115
132
  isStarted(): boolean;
116
133
  /**
117
134
  * Starts the Connection Manager. If Metrics are not enabled on libp2p
@@ -119,15 +136,10 @@ export declare class DefaultConnectionManager extends EventEmitter<ConnectionMan
119
136
  */
120
137
  start(): Promise<void>;
121
138
  afterStart(): Promise<void>;
122
- beforeStop(): Promise<void>;
123
139
  /**
124
140
  * Stops the Connection Manager
125
141
  */
126
142
  stop(): Promise<void>;
127
- /**
128
- * Cleans up the connections
129
- */
130
- _close(): Promise<void>;
131
143
  onConnect(evt: CustomEvent<Connection>): void;
132
144
  /**
133
145
  * Tracks the incoming connection and check the connection limit
@@ -138,27 +150,11 @@ export declare class DefaultConnectionManager extends EventEmitter<ConnectionMan
138
150
  */
139
151
  onDisconnect(evt: CustomEvent<Connection>): void;
140
152
  getConnections(peerId?: PeerId): Connection[];
141
- getConnectionsMap(): Map<string, Connection[]>;
142
- openConnection(peerIdOrMultiaddr: PeerId | Multiaddr, options?: AbortOptions): Promise<Connection>;
153
+ getConnectionsMap(): PeerMap<Connection[]>;
154
+ openConnection(peerIdOrMultiaddr: PeerId | Multiaddr | Multiaddr[], options?: OpenConnectionOptions): Promise<Connection>;
143
155
  closeConnections(peerId: PeerId): Promise<void>;
144
- /**
145
- * Get all open connections with a peer
146
- */
147
- getAll(peerId: PeerId): Connection[];
148
- /**
149
- * If the event loop is slow, maybe close a connection
150
- */
151
- _onLatencyMeasure(evt: CustomEvent<SummaryObject>): void;
152
- /**
153
- * If the `value` of `name` has exceeded its limit, maybe close a connection
154
- */
155
- _checkMaxLimit(name: keyof ConnectionManagerInit, value: number, toPrune?: number): Promise<void>;
156
- /**
157
- * If we have more connections than our maximum, select some excess connections
158
- * to prune based on peer value
159
- */
160
- _pruneConnections(toPrune: number): Promise<void>;
161
156
  acceptIncomingConnection(maConn: MultiaddrConnection): Promise<boolean>;
162
157
  afterUpgradeInbound(): void;
158
+ getDialQueue(): PendingDial[];
163
159
  }
164
160
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/connection-manager/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAkB,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,EAAe,YAAY,EAAE,MAAM,2BAA2B,CAAA;AACrE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAA;AAE7D,OAAO,EAAY,MAAM,EAAE,MAAM,2BAA2B,CAAA;AAE5D,OAAO,KAAK,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAA;AACnF,OAAO,KAAK,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAA;AAE9G,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAA;AAC5E,OAAO,EAAa,SAAS,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAA;AAKxE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAA;AACxD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAA;AAK3D,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,cAAc,EAAE,MAAM,CAAA;IAEtB;;OAEG;IACH,cAAc,EAAE,MAAM,CAAA;IAEtB;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAE1B;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IAErB;;;OAGG;IACH,gBAAgB,EAAE,MAAM,CAAA;IAExB;;OAEG;IACH,aAAa,CAAC,EAAE,aAAa,CAAA;IAE7B;;OAEG;IACH,gBA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