libp2p 0.36.0 → 0.36.2-1473044
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.
- package/LICENSE +3 -21
- package/README.md +13 -10
- package/dist/src/address-manager/index.d.ts +33 -52
- package/dist/src/address-manager/index.d.ts.map +1 -1
- package/dist/src/address-manager/index.js +81 -0
- package/dist/src/address-manager/index.js.map +1 -0
- package/dist/src/circuit/auto-relay.d.ts +24 -85
- package/dist/src/circuit/auto-relay.d.ts.map +1 -1
- package/dist/src/circuit/auto-relay.js +215 -0
- package/dist/src/circuit/auto-relay.js.map +1 -0
- package/dist/src/circuit/circuit/hop.d.ts +26 -53
- package/dist/src/circuit/circuit/hop.d.ts.map +1 -1
- package/dist/src/circuit/circuit/hop.js +138 -0
- package/dist/src/circuit/circuit/hop.js.map +1 -0
- package/dist/src/circuit/circuit/stop.d.ts +18 -10
- package/dist/src/circuit/circuit/stop.d.ts.map +1 -1
- package/dist/src/circuit/circuit/stop.js +49 -0
- package/dist/src/circuit/circuit/stop.js.map +1 -0
- package/dist/src/circuit/circuit/stream-handler.d.ts +19 -38
- package/dist/src/circuit/circuit/stream-handler.d.ts.map +1 -1
- package/dist/src/circuit/circuit/stream-handler.js +59 -0
- package/dist/src/circuit/circuit/stream-handler.js.map +1 -0
- package/dist/src/circuit/circuit/utils.d.ts +3 -6
- package/dist/src/circuit/circuit/utils.d.ts.map +1 -1
- package/dist/src/circuit/circuit/utils.js +43 -0
- package/dist/src/circuit/circuit/utils.js.map +1 -0
- package/dist/src/circuit/constants.d.ts +24 -6
- package/dist/src/circuit/constants.d.ts.map +1 -1
- package/dist/src/circuit/constants.js +26 -0
- package/dist/src/circuit/constants.js.map +1 -0
- package/dist/src/circuit/index.d.ts +41 -74
- package/dist/src/circuit/index.d.ts.map +1 -1
- package/dist/src/circuit/index.js +69 -0
- package/dist/src/circuit/index.js.map +1 -0
- package/dist/src/circuit/listener.d.ts +8 -3
- package/dist/src/circuit/listener.d.ts.map +1 -1
- package/dist/src/circuit/listener.js +54 -0
- package/dist/src/circuit/listener.js.map +1 -0
- package/dist/src/circuit/multicodec.d.ts +1 -1
- package/dist/src/circuit/multicodec.d.ts.map +1 -1
- package/dist/src/circuit/multicodec.js +2 -0
- package/dist/src/circuit/multicodec.js.map +1 -0
- package/dist/src/circuit/pb/index.d.ts +51 -0
- package/dist/src/circuit/pb/index.d.ts.map +1 -0
- package/dist/src/circuit/pb/index.js +72 -0
- package/dist/src/circuit/pb/index.js.map +1 -0
- package/dist/src/circuit/transport.d.ts +18 -78
- package/dist/src/circuit/transport.d.ts.map +1 -1
- package/dist/src/circuit/transport.js +190 -0
- package/dist/src/circuit/transport.js.map +1 -0
- package/dist/src/circuit/utils.d.ts +5 -2
- package/dist/src/circuit/utils.d.ts.map +1 -1
- package/dist/src/circuit/utils.js +11 -0
- package/dist/src/circuit/utils.js.map +1 -0
- package/dist/src/config.d.ts +3 -85
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +93 -0
- package/dist/src/config.js.map +1 -0
- package/dist/src/connection-manager/auto-dialler.d.ts +24 -41
- package/dist/src/connection-manager/auto-dialler.d.ts.map +1 -1
- package/dist/src/connection-manager/auto-dialler.js +105 -0
- package/dist/src/connection-manager/auto-dialler.js.map +1 -0
- package/dist/src/connection-manager/index.d.ts +79 -144
- package/dist/src/connection-manager/index.d.ts.map +1 -1
- package/dist/src/connection-manager/index.js +295 -0
- package/dist/src/connection-manager/index.js.map +1 -0
- package/dist/src/connection-manager/latency-monitor.d.ts +72 -97
- package/dist/src/connection-manager/latency-monitor.d.ts.map +1 -1
- package/dist/src/connection-manager/latency-monitor.js +220 -0
- package/dist/src/connection-manager/latency-monitor.js.map +1 -0
- package/dist/src/connection-manager/visibility-change-emitter.d.ts +15 -16
- package/dist/src/connection-manager/visibility-change-emitter.d.ts.map +1 -1
- package/dist/src/connection-manager/visibility-change-emitter.js +118 -0
- package/dist/src/connection-manager/visibility-change-emitter.js.map +1 -0
- package/dist/src/constants.d.ts +22 -10
- package/dist/src/constants.d.ts.map +1 -1
- package/dist/src/constants.js +27 -0
- package/dist/src/constants.js.map +1 -0
- package/dist/src/content-routing/index.d.ts +26 -81
- package/dist/src/content-routing/index.d.ts.map +1 -1
- package/dist/src/content-routing/index.js +99 -0
- package/dist/src/content-routing/index.js.map +1 -0
- package/dist/src/content-routing/utils.d.ts +6 -49
- package/dist/src/content-routing/utils.d.ts.map +1 -1
- package/dist/src/content-routing/utils.js +42 -0
- package/dist/src/content-routing/utils.js.map +1 -0
- package/dist/src/dht/dht-content-routing.d.ts +10 -24
- package/dist/src/dht/dht-content-routing.d.ts.map +1 -1
- package/dist/src/dht/dht-content-routing.js +32 -0
- package/dist/src/dht/dht-content-routing.js.map +1 -0
- package/dist/src/dht/dht-peer-routing.d.ts +9 -24
- package/dist/src/dht/dht-peer-routing.d.ts.map +1 -1
- package/dist/src/dht/dht-peer-routing.js +26 -0
- package/dist/src/dht/dht-peer-routing.js.map +1 -0
- package/dist/src/dialer/auto-dialer.d.ts +14 -0
- package/dist/src/dialer/auto-dialer.d.ts.map +1 -0
- package/dist/src/dialer/auto-dialer.js +24 -0
- package/dist/src/dialer/auto-dialer.js.map +1 -0
- package/dist/src/dialer/dial-request.d.ts +18 -46
- package/dist/src/dialer/dial-request.d.ts.map +1 -1
- package/dist/src/dialer/dial-request.js +83 -0
- package/dist/src/dialer/dial-request.js.map +1 -0
- package/dist/src/dialer/index.d.ts +41 -148
- package/dist/src/dialer/index.d.ts.map +1 -1
- package/dist/src/dialer/index.js +280 -0
- package/dist/src/dialer/index.js.map +1 -0
- package/dist/src/errors.d.ts +68 -63
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/errors.js +73 -0
- package/dist/src/errors.js.map +1 -0
- package/dist/src/fetch/constants.d.ts +1 -1
- package/dist/src/fetch/constants.d.ts.map +1 -1
- package/dist/src/fetch/constants.js +3 -0
- package/dist/src/fetch/constants.js.map +1 -0
- package/dist/src/fetch/index.d.ts +30 -49
- package/dist/src/fetch/index.d.ts.map +1 -1
- package/dist/src/fetch/index.js +129 -0
- package/dist/src/fetch/index.js.map +1 -0
- package/dist/src/fetch/pb/proto.d.ts +26 -0
- package/dist/src/fetch/pb/proto.d.ts.map +1 -0
- package/dist/src/fetch/pb/proto.js +44 -0
- package/dist/src/fetch/pb/proto.js.map +1 -0
- package/dist/src/get-peer.d.ts +4 -11
- package/dist/src/get-peer.d.ts.map +1 -1
- package/dist/src/get-peer.js +43 -0
- package/dist/src/get-peer.js.map +1 -0
- package/dist/src/identify/consts.d.ts +9 -9
- package/dist/src/identify/consts.d.ts.map +1 -1
- package/dist/src/identify/consts.js +11 -0
- package/dist/src/identify/consts.js.map +1 -0
- package/dist/src/identify/index.d.ts +42 -96
- package/dist/src/identify/index.d.ts.map +1 -1
- package/dist/src/identify/index.js +322 -0
- package/dist/src/identify/index.js.map +1 -0
- package/dist/src/identify/pb/message.d.ts +15 -0
- package/dist/src/identify/pb/message.d.ts.map +1 -0
- package/dist/src/identify/pb/message.js +24 -0
- package/dist/src/identify/pb/message.js.map +1 -0
- package/dist/src/index.d.ts +162 -581
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +9 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/insecure/index.d.ts +9 -0
- package/dist/src/insecure/index.d.ts.map +1 -0
- package/dist/src/insecure/index.js +81 -0
- package/dist/src/insecure/index.js.map +1 -0
- package/dist/src/insecure/pb/proto.d.ts +28 -0
- package/dist/src/insecure/pb/proto.d.ts.map +1 -0
- package/dist/src/insecure/pb/proto.js +46 -0
- package/dist/src/insecure/pb/proto.js.map +1 -0
- package/dist/src/keychain/cms.d.ts +6 -14
- package/dist/src/keychain/cms.d.ts.map +1 -1
- package/dist/src/keychain/cms.js +129 -0
- package/dist/src/keychain/cms.js.map +1 -0
- package/dist/src/keychain/index.d.ts +61 -81
- package/dist/src/keychain/index.d.ts.map +1 -1
- package/dist/src/keychain/index.js +493 -0
- package/dist/src/keychain/index.js.map +1 -0
- package/dist/src/keychain/util.d.ts +3 -6
- package/dist/src/keychain/util.d.ts.map +1 -1
- package/dist/src/keychain/util.js +79 -0
- package/dist/src/keychain/util.js.map +1 -0
- package/dist/src/libp2p.d.ts +78 -0
- package/dist/src/libp2p.d.ts.map +1 -0
- package/dist/src/libp2p.js +375 -0
- package/dist/src/libp2p.js.map +1 -0
- package/dist/src/metrics/index.d.ts +47 -104
- package/dist/src/metrics/index.d.ts.map +1 -1
- package/dist/src/metrics/index.js +231 -0
- package/dist/src/metrics/index.js.map +1 -0
- package/dist/src/metrics/moving-average.d.ts +14 -0
- package/dist/src/metrics/moving-average.d.ts.map +1 -0
- package/dist/src/metrics/moving-average.js +40 -0
- package/dist/src/metrics/moving-average.js.map +1 -0
- package/dist/src/metrics/stats.d.ts +41 -93
- package/dist/src/metrics/stats.d.ts.map +1 -1
- package/dist/src/metrics/stats.js +183 -0
- package/dist/src/metrics/stats.js.map +1 -0
- package/dist/src/nat-manager.d.ts +42 -99
- package/dist/src/nat-manager.d.ts.map +1 -1
- package/dist/src/nat-manager.js +114 -0
- package/dist/src/nat-manager.js.map +1 -0
- package/dist/src/peer-record-updater.d.ts +15 -0
- package/dist/src/peer-record-updater.d.ts.map +1 -0
- package/dist/src/peer-record-updater.js +44 -0
- package/dist/src/peer-record-updater.js.map +1 -0
- package/dist/src/peer-routing.d.ts +39 -84
- package/dist/src/peer-routing.d.ts.map +1 -1
- package/dist/src/peer-routing.js +108 -0
- package/dist/src/peer-routing.js.map +1 -0
- package/dist/src/ping/constants.d.ts +4 -4
- package/dist/src/ping/constants.d.ts.map +1 -1
- package/dist/src/ping/constants.js +5 -0
- package/dist/src/ping/constants.js.map +1 -0
- package/dist/src/ping/index.d.ts +26 -33
- package/dist/src/ping/index.d.ts.map +1 -1
- package/dist/src/ping/index.js +56 -0
- package/dist/src/ping/index.js.map +1 -0
- package/dist/src/pnet/crypto.d.ts +15 -5
- package/dist/src/pnet/crypto.d.ts.map +1 -1
- package/dist/src/pnet/crypto.js +60 -0
- package/dist/src/pnet/crypto.js.map +1 -0
- package/dist/src/pnet/errors.d.ts +5 -5
- package/dist/src/pnet/errors.d.ts.map +1 -1
- package/dist/src/pnet/errors.js +6 -0
- package/dist/src/pnet/errors.js.map +1 -0
- package/dist/src/pnet/index.d.ts +11 -20
- package/dist/src/pnet/index.d.ts.map +1 -1
- package/dist/src/pnet/index.js +66 -0
- package/dist/src/pnet/index.js.map +1 -0
- package/dist/src/pnet/key-generator.d.ts +3 -7
- package/dist/src/pnet/key-generator.d.ts.map +1 -1
- package/dist/src/pnet/key-generator.js +25 -0
- package/dist/src/pnet/key-generator.js.map +1 -0
- package/dist/src/registrar.d.ts +27 -65
- package/dist/src/registrar.d.ts.map +1 -1
- package/dist/src/registrar.js +159 -0
- package/dist/src/registrar.js.map +1 -0
- package/dist/src/transport-manager.d.ts +34 -82
- package/dist/src/transport-manager.d.ts.map +1 -1
- package/dist/src/transport-manager.js +223 -0
- package/dist/src/transport-manager.js.map +1 -0
- package/dist/src/upgrader.d.ts +49 -129
- package/dist/src/upgrader.d.ts.map +1 -1
- package/dist/src/upgrader.js +402 -0
- package/dist/src/upgrader.js.map +1 -0
- package/dist/src/version.d.ts +3 -0
- package/dist/src/version.d.ts.map +1 -0
- package/dist/src/version.js +3 -0
- package/dist/src/version.js.map +1 -0
- package/package.json +150 -197
- package/src/address-manager/index.ts +129 -0
- package/src/circuit/README.md +16 -11
- package/src/circuit/auto-relay.ts +284 -0
- package/src/circuit/circuit/hop.ts +211 -0
- package/src/circuit/circuit/stop.ts +78 -0
- package/src/circuit/circuit/stream-handler.ts +86 -0
- package/src/circuit/circuit/{utils.js → utils.ts} +9 -25
- package/src/circuit/constants.ts +31 -0
- package/src/circuit/index.ts +120 -0
- package/src/circuit/{listener.js → listener.ts} +21 -27
- package/src/circuit/multicodec.ts +2 -0
- package/src/circuit/{protocol → pb}/index.proto +1 -1
- package/src/circuit/pb/index.ts +88 -0
- package/src/circuit/transport.ts +216 -0
- package/src/circuit/utils.ts +12 -0
- package/src/config.ts +101 -0
- package/src/connection-manager/auto-dialler.ts +154 -0
- package/src/connection-manager/index.ts +422 -0
- package/src/connection-manager/latency-monitor.ts +319 -0
- package/src/connection-manager/{visibility-change-emitter.js → visibility-change-emitter.ts} +48 -38
- package/src/constants.ts +31 -0
- package/src/content-routing/index.ts +143 -0
- package/src/content-routing/utils.ts +54 -0
- package/src/dht/dht-content-routing.ts +43 -0
- package/src/dht/dht-peer-routing.ts +35 -0
- package/src/dialer/auto-dialer.ts +40 -0
- package/src/dialer/{dial-request.js → dial-request.ts} +60 -51
- package/src/dialer/index.ts +371 -0
- package/src/errors.ts +71 -0
- package/src/fetch/README.md +1 -1
- package/src/fetch/constants.ts +3 -0
- package/src/fetch/index.ts +167 -0
- package/src/fetch/{proto.proto → pb/proto.proto} +0 -0
- package/src/fetch/pb/proto.ts +58 -0
- package/src/get-peer.ts +57 -0
- package/src/identify/consts.ts +13 -0
- package/src/identify/index.ts +445 -0
- package/src/identify/{message.proto → pb/message.proto} +0 -0
- package/src/identify/pb/message.ts +36 -0
- package/src/index.ts +242 -0
- package/src/insecure/index.ts +101 -0
- package/src/insecure/{proto.proto → pb/proto.proto} +0 -0
- package/src/insecure/pb/proto.ts +61 -0
- package/src/keychain/{cms.js → cms.ts} +62 -58
- package/src/keychain/index.ts +588 -0
- package/src/keychain/{util.js → util.ts} +7 -17
- package/src/libp2p.ts +513 -0
- package/src/metrics/index.ts +310 -0
- package/src/metrics/moving-average.ts +53 -0
- package/src/metrics/stats.ts +238 -0
- package/src/nat-manager.ts +194 -0
- package/src/peer-record-updater.ts +55 -0
- package/src/peer-routing.ts +185 -0
- package/src/ping/README.md +1 -1
- package/src/ping/constants.ts +5 -0
- package/src/ping/index.ts +83 -0
- package/src/pnet/README.md +2 -2
- package/src/pnet/crypto.ts +67 -0
- package/src/pnet/errors.ts +5 -0
- package/src/pnet/index.ts +95 -0
- package/src/pnet/key-generator.ts +28 -0
- package/src/registrar.ts +205 -0
- package/src/transport-manager.ts +279 -0
- package/src/upgrader.ts +499 -0
- package/src/version.ts +3 -0
- package/dist/index.min.js +0 -55
- package/dist/src/circuit/protocol/index.d.ts +0 -173
- package/dist/src/fetch/proto.d.ts +0 -134
- package/dist/src/identify/message.d.ts +0 -95
- package/dist/src/insecure/plaintext.d.ts +0 -12
- package/dist/src/insecure/plaintext.d.ts.map +0 -1
- package/dist/src/insecure/proto.d.ts +0 -128
- package/dist/src/metrics/old-peers.d.ts +0 -3
- package/dist/src/metrics/old-peers.d.ts.map +0 -1
- package/dist/src/metrics/tracked-map.d.ts +0 -8
- package/dist/src/metrics/tracked-map.d.ts.map +0 -1
- package/dist/src/peer-store/address-book.d.ts +0 -67
- package/dist/src/peer-store/address-book.d.ts.map +0 -1
- package/dist/src/peer-store/index.d.ts +0 -58
- package/dist/src/peer-store/index.d.ts.map +0 -1
- package/dist/src/peer-store/key-book.d.ts +0 -40
- package/dist/src/peer-store/key-book.d.ts.map +0 -1
- package/dist/src/peer-store/metadata-book.d.ts +0 -58
- package/dist/src/peer-store/metadata-book.d.ts.map +0 -1
- package/dist/src/peer-store/pb/peer.d.ts +0 -222
- package/dist/src/peer-store/proto-book.d.ts +0 -43
- package/dist/src/peer-store/proto-book.d.ts.map +0 -1
- package/dist/src/peer-store/store.d.ts +0 -73
- package/dist/src/peer-store/store.d.ts.map +0 -1
- package/dist/src/peer-store/types.d.ts +0 -202
- package/dist/src/peer-store/types.d.ts.map +0 -1
- package/dist/src/ping/util.d.ts +0 -5
- package/dist/src/ping/util.d.ts.map +0 -1
- package/dist/src/pubsub-adapter.d.ts +0 -22
- package/dist/src/pubsub-adapter.d.ts.map +0 -1
- package/dist/src/record/envelope/envelope.d.ts +0 -77
- package/dist/src/record/envelope/index.d.ts +0 -80
- package/dist/src/record/envelope/index.d.ts.map +0 -1
- package/dist/src/record/peer-record/consts.d.ts +0 -4
- package/dist/src/record/peer-record/consts.d.ts.map +0 -1
- package/dist/src/record/peer-record/index.d.ts +0 -60
- package/dist/src/record/peer-record/index.d.ts.map +0 -1
- package/dist/src/record/peer-record/peer-record.d.ts +0 -133
- package/dist/src/record/utils.d.ts +0 -12
- package/dist/src/record/utils.d.ts.map +0 -1
- package/dist/src/types.d.ts +0 -90
- package/dist/src/types.d.ts.map +0 -1
- package/src/address-manager/index.js +0 -96
- package/src/circuit/auto-relay.js +0 -302
- package/src/circuit/circuit/hop.js +0 -205
- package/src/circuit/circuit/stop.js +0 -81
- package/src/circuit/circuit/stream-handler.js +0 -94
- package/src/circuit/constants.js +0 -12
- package/src/circuit/index.js +0 -102
- package/src/circuit/multicodec.js +0 -5
- package/src/circuit/protocol/index.d.ts +0 -173
- package/src/circuit/protocol/index.js +0 -530
- package/src/circuit/transport.js +0 -229
- package/src/circuit/utils.js +0 -17
- package/src/config.js +0 -114
- package/src/connection-manager/auto-dialler.js +0 -132
- package/src/connection-manager/index.js +0 -363
- package/src/connection-manager/latency-monitor.js +0 -264
- package/src/constants.js +0 -18
- package/src/content-routing/index.js +0 -163
- package/src/content-routing/utils.js +0 -89
- package/src/dht/dht-content-routing.js +0 -44
- package/src/dht/dht-peer-routing.js +0 -51
- package/src/dialer/index.js +0 -376
- package/src/errors.js +0 -66
- package/src/fetch/constants.js +0 -6
- package/src/fetch/index.js +0 -159
- package/src/fetch/proto.d.ts +0 -134
- package/src/fetch/proto.js +0 -333
- package/src/get-peer.js +0 -49
- package/src/identify/consts.js +0 -15
- package/src/identify/index.js +0 -384
- package/src/identify/message.d.ts +0 -95
- package/src/identify/message.js +0 -328
- package/src/index.js +0 -811
- package/src/insecure/plaintext.js +0 -95
- package/src/insecure/proto.d.ts +0 -128
- package/src/insecure/proto.js +0 -371
- package/src/keychain/index.js +0 -561
- package/src/metrics/index.js +0 -290
- package/src/metrics/old-peers.js +0 -16
- package/src/metrics/stats.js +0 -270
- package/src/metrics/tracked-map.js +0 -94
- package/src/nat-manager.js +0 -197
- package/src/peer-routing.js +0 -176
- package/src/peer-store/README.md +0 -145
- package/src/peer-store/address-book.js +0 -382
- package/src/peer-store/index.js +0 -121
- package/src/peer-store/key-book.js +0 -141
- package/src/peer-store/metadata-book.js +0 -250
- package/src/peer-store/pb/peer.d.ts +0 -222
- package/src/peer-store/pb/peer.js +0 -643
- package/src/peer-store/pb/peer.proto +0 -31
- package/src/peer-store/proto-book.js +0 -237
- package/src/peer-store/store.js +0 -263
- package/src/peer-store/types.ts +0 -245
- package/src/ping/constants.js +0 -8
- package/src/ping/index.js +0 -85
- package/src/ping/util.js +0 -18
- package/src/pnet/crypto.js +0 -84
- package/src/pnet/errors.js +0 -7
- package/src/pnet/index.js +0 -86
- package/src/pnet/key-generator.js +0 -33
- package/src/pubsub-adapter.js +0 -61
- package/src/record/README.md +0 -130
- package/src/record/envelope/envelope.d.ts +0 -77
- package/src/record/envelope/envelope.js +0 -243
- package/src/record/envelope/envelope.proto +0 -19
- package/src/record/envelope/index.js +0 -183
- package/src/record/peer-record/consts.js +0 -14
- package/src/record/peer-record/index.js +0 -113
- package/src/record/peer-record/peer-record.d.ts +0 -133
- package/src/record/peer-record/peer-record.js +0 -367
- package/src/record/peer-record/peer-record.proto +0 -18
- package/src/record/utils.js +0 -25
- package/src/registrar.js +0 -127
- package/src/transport-manager.js +0 -269
- package/src/types.ts +0 -98
- package/src/upgrader.js +0 -492
|
@@ -1,193 +1,128 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
* @property {number} [maxReceivedData = Infinity] - The max incoming data, per average interval to allow.
|
|
13
|
-
* @property {number} [maxEventLoopDelay = Infinity] - The upper limit the event loop can take to run.
|
|
14
|
-
* @property {number} [pollInterval = 2000] - How often, in milliseconds, metrics and latency should be checked.
|
|
15
|
-
* @property {number} [movingAverageInterval = 60000] - How often, in milliseconds, to compute averages.
|
|
16
|
-
* @property {number} [defaultPeerValue = 1] - The value of the peer.
|
|
17
|
-
* @property {boolean} [autoDial = true] - Should preemptively guarantee connections are above the low watermark.
|
|
18
|
-
* @property {number} [autoDialInterval = 10000] - How often, in milliseconds, it should preemptively guarantee connections are above the low watermark.
|
|
19
|
-
*/
|
|
20
|
-
/**
|
|
21
|
-
*
|
|
22
|
-
* @fires ConnectionManager#peer:connect Emitted when a new peer is connected.
|
|
23
|
-
* @fires ConnectionManager#peer:disconnect Emitted when a peer is disconnected.
|
|
24
|
-
*/
|
|
25
|
-
declare class ConnectionManager extends EventEmitter {
|
|
1
|
+
import { SummaryObject } from './latency-monitor.js';
|
|
2
|
+
import { EventEmitter, Startable } from '@libp2p/interfaces';
|
|
3
|
+
import { PeerId } from '@libp2p/interfaces/peer-id';
|
|
4
|
+
import type { Connection } from '@libp2p/interfaces/connection';
|
|
5
|
+
import type { ConnectionManager } from '@libp2p/interfaces/registrar';
|
|
6
|
+
import type { Components } from '@libp2p/interfaces/components';
|
|
7
|
+
export interface ConnectionManagerEvents {
|
|
8
|
+
'peer:connect': CustomEvent<PeerId>;
|
|
9
|
+
'peer:disconnect': CustomEvent<PeerId>;
|
|
10
|
+
}
|
|
11
|
+
export interface ConnectionManagerInit {
|
|
26
12
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* @class
|
|
30
|
-
* @param {Libp2p} libp2p
|
|
31
|
-
* @param {ConnectionManagerOptions} options
|
|
13
|
+
* The maximum number of connections allowed
|
|
32
14
|
*/
|
|
33
|
-
|
|
34
|
-
_libp2p: import("../");
|
|
35
|
-
_peerId: string;
|
|
36
|
-
_options: any;
|
|
15
|
+
maxConnections?: number;
|
|
37
16
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* @type {Map<string, number>}
|
|
17
|
+
* The minimum number of connections to avoid pruning
|
|
41
18
|
*/
|
|
42
|
-
|
|
19
|
+
minConnections?: number;
|
|
43
20
|
/**
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
* @type {Map<string, Connection[]>}
|
|
21
|
+
* The max data (in and out), per average interval to allow
|
|
47
22
|
*/
|
|
48
|
-
|
|
49
|
-
_started: boolean;
|
|
50
|
-
_timer: any;
|
|
23
|
+
maxData?: number;
|
|
51
24
|
/**
|
|
52
|
-
*
|
|
53
|
-
* the configured maximums.
|
|
54
|
-
*
|
|
55
|
-
* @private
|
|
25
|
+
* The max outgoing data, per average interval to allow
|
|
56
26
|
*/
|
|
57
|
-
|
|
58
|
-
_latencyMonitor: LatencyMonitor;
|
|
27
|
+
maxSentData?: number;
|
|
59
28
|
/**
|
|
60
|
-
*
|
|
29
|
+
* The max incoming data, per average interval to allow
|
|
61
30
|
*/
|
|
62
|
-
|
|
31
|
+
maxReceivedData?: number;
|
|
63
32
|
/**
|
|
64
|
-
*
|
|
65
|
-
* only event loop and connection limits will be monitored.
|
|
33
|
+
* The upper limit the event loop can take to run
|
|
66
34
|
*/
|
|
67
|
-
|
|
35
|
+
maxEventLoopDelay?: number;
|
|
68
36
|
/**
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
* @private
|
|
72
|
-
* @param {*} summary - The LatencyMonitor summary
|
|
37
|
+
* How often, in milliseconds, metrics and latency should be checked
|
|
73
38
|
*/
|
|
74
|
-
|
|
39
|
+
pollInterval?: number;
|
|
75
40
|
/**
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
* @async
|
|
41
|
+
* How often, in milliseconds, to compute averages
|
|
79
42
|
*/
|
|
80
|
-
|
|
43
|
+
movingAverageInterval?: number;
|
|
81
44
|
/**
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
* @async
|
|
45
|
+
* The value of the peer
|
|
85
46
|
*/
|
|
86
|
-
|
|
47
|
+
defaultPeerValue?: number;
|
|
87
48
|
/**
|
|
88
|
-
*
|
|
89
|
-
* will be disconnected first.
|
|
90
|
-
*
|
|
91
|
-
* @param {PeerId} peerId
|
|
92
|
-
* @param {number} value - A number between 0 and 1
|
|
93
|
-
* @returns {void}
|
|
49
|
+
* Should preemptively guarantee connections are above the low watermark
|
|
94
50
|
*/
|
|
95
|
-
|
|
51
|
+
autoDial?: boolean;
|
|
96
52
|
/**
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
* @param {Connection} connection
|
|
53
|
+
* How often, in milliseconds, it should preemptively guarantee connections are above the low watermark
|
|
100
54
|
*/
|
|
101
|
-
|
|
55
|
+
autoDialInterval?: number;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Responsible for managing known connections.
|
|
59
|
+
*/
|
|
60
|
+
export declare class DefaultConnectionManager extends EventEmitter<ConnectionManagerEvents> implements ConnectionManager, Startable {
|
|
61
|
+
private readonly components;
|
|
62
|
+
private readonly init;
|
|
63
|
+
private readonly peerValues;
|
|
64
|
+
private readonly connections;
|
|
65
|
+
private started;
|
|
66
|
+
private timer?;
|
|
67
|
+
private readonly latencyMonitor;
|
|
68
|
+
constructor(components: Components, init?: ConnectionManagerInit);
|
|
69
|
+
isStarted(): boolean;
|
|
102
70
|
/**
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
* @param {Connection} connection
|
|
106
|
-
* @returns {void}
|
|
71
|
+
* Starts the Connection Manager. If Metrics are not enabled on libp2p
|
|
72
|
+
* only event loop and connection limits will be monitored.
|
|
107
73
|
*/
|
|
108
|
-
|
|
74
|
+
start(): Promise<void>;
|
|
109
75
|
/**
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
* @param {PeerId} peerId
|
|
113
|
-
* @returns {Connection|null}
|
|
76
|
+
* Stops the Connection Manager
|
|
114
77
|
*/
|
|
115
|
-
|
|
78
|
+
stop(): Promise<void>;
|
|
116
79
|
/**
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
* @param {PeerId} peerId
|
|
120
|
-
* @returns {Connection[]}
|
|
80
|
+
* Cleans up the connections
|
|
121
81
|
*/
|
|
122
|
-
|
|
82
|
+
_close(): Promise<void>;
|
|
123
83
|
/**
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
* @private
|
|
127
|
-
* @param {string} name - The name of the field to check limits for
|
|
128
|
-
* @param {number} value - The current value of the field
|
|
84
|
+
* Sets the value of the given peer. Peers with lower values
|
|
85
|
+
* will be disconnected first.
|
|
129
86
|
*/
|
|
130
|
-
|
|
87
|
+
setPeerValue(peerId: PeerId, value: number): void;
|
|
131
88
|
/**
|
|
132
|
-
*
|
|
133
|
-
*
|
|
89
|
+
* Checks the libp2p metrics to determine if any values have exceeded
|
|
90
|
+
* the configured maximums.
|
|
134
91
|
*
|
|
135
92
|
* @private
|
|
136
93
|
*/
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
declare namespace ConnectionManager {
|
|
140
|
-
export { Libp2p, Connection, ConnectionManagerOptions };
|
|
141
|
-
}
|
|
142
|
-
import { EventEmitter } from "events";
|
|
143
|
-
type Connection = import("libp2p-interfaces/src/connection/connection");
|
|
144
|
-
import LatencyMonitor = require("./latency-monitor");
|
|
145
|
-
import PeerId = require("peer-id");
|
|
146
|
-
type Libp2p = import('../');
|
|
147
|
-
type ConnectionManagerOptions = {
|
|
148
|
-
/**
|
|
149
|
-
* - The maximum number of connections allowed.
|
|
150
|
-
*/
|
|
151
|
-
maxConnections?: number | undefined;
|
|
152
|
-
/**
|
|
153
|
-
* - The minimum number of connections to avoid pruning.
|
|
154
|
-
*/
|
|
155
|
-
minConnections?: number | undefined;
|
|
156
|
-
/**
|
|
157
|
-
* - The max data (in and out), per average interval to allow.
|
|
158
|
-
*/
|
|
159
|
-
maxData?: number | undefined;
|
|
160
|
-
/**
|
|
161
|
-
* - The max outgoing data, per average interval to allow.
|
|
162
|
-
*/
|
|
163
|
-
maxSentData?: number | undefined;
|
|
94
|
+
_checkMetrics(): Promise<void>;
|
|
164
95
|
/**
|
|
165
|
-
*
|
|
96
|
+
* Tracks the incoming connection and check the connection limit
|
|
166
97
|
*/
|
|
167
|
-
|
|
98
|
+
onConnect(evt: CustomEvent<Connection>): Promise<void>;
|
|
168
99
|
/**
|
|
169
|
-
*
|
|
100
|
+
* Removes the connection from tracking
|
|
170
101
|
*/
|
|
171
|
-
|
|
102
|
+
onDisconnect(evt: CustomEvent<Connection>): void;
|
|
103
|
+
getConnectionMap(): Map<string, Connection[]>;
|
|
104
|
+
getConnectionList(): Connection[];
|
|
105
|
+
getConnections(peerId: PeerId): Connection[];
|
|
172
106
|
/**
|
|
173
|
-
*
|
|
107
|
+
* Get a connection with a peer
|
|
174
108
|
*/
|
|
175
|
-
|
|
109
|
+
getConnection(peerId: PeerId): Connection | undefined;
|
|
176
110
|
/**
|
|
177
|
-
*
|
|
111
|
+
* Get all open connections with a peer
|
|
178
112
|
*/
|
|
179
|
-
|
|
113
|
+
getAll(peerId: PeerId): Connection[];
|
|
180
114
|
/**
|
|
181
|
-
*
|
|
115
|
+
* If the event loop is slow, maybe close a connection
|
|
182
116
|
*/
|
|
183
|
-
|
|
117
|
+
_onLatencyMeasure(evt: CustomEvent<SummaryObject>): void;
|
|
184
118
|
/**
|
|
185
|
-
*
|
|
119
|
+
* If the `value` of `name` has exceeded its limit, maybe close a connection
|
|
186
120
|
*/
|
|
187
|
-
|
|
121
|
+
_checkMaxLimit(name: keyof ConnectionManagerInit, value: number): Promise<void>;
|
|
188
122
|
/**
|
|
189
|
-
*
|
|
123
|
+
* If we have more connections than our maximum, close a connection
|
|
124
|
+
* to the lowest valued peer.
|
|
190
125
|
*/
|
|
191
|
-
|
|
192
|
-
}
|
|
126
|
+
_maybeDisconnectOne(): Promise<void>;
|
|
127
|
+
}
|
|
193
128
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/connection-manager/index.
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/connection-manager/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAkB,aAAa,EAAE,MAAM,sBAAs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AAqB;IAChD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA2B;IACvD,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,KAAK,CAAC,CAAqB;IACnC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAgB;gBAElC,UAAU,EAAE,UAAU,EAAE,IAAI,GAAE,qBAA0B;IAqDrE,SAAS;IAIT;;;OAGG;IACG,KAAK;IAcX;;OAEG;IACG,IAAI;IAWV;;OAEG;IACG,MAAM;IAcZ;;;OAGG;IACH,YAAY,CAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAQ3C;;;;;OAKG;IACG,aAAa;IAmBnB;;OAEG;IACG,SAAS,CAAE,GAAG,EAAE,WAAW,CAAC,UAAU,CAAC;IAgC7C;;OAEG;IACH,YAAY,CAAE,GAAG,EAAE,WAAW,CAAC,UAAU,CAAC;IAuB1C,gBAAgB,IAAK,GAAG,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC;IAI9C,iBAAiB,IAAK,UAAU,EAAE;IAUlC,cAAc,CAAE,MAAM,EAAE,MAAM,GAAG,UAAU,EAAE;IAI7C;;OAEG;IACH,aAAa,CAAE,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS;IAUtD;;OAEG;IACH,MAAM,CAAE,MAAM,EAAE,MAAM,GAAG,UAAU,EAAE;IAgBrC;;OAEG;IACH,iBAAiB,CAAE,GAAG,EAAE,WAAW,CAAC,aAAa,CAAC;IASlD;;OAEG;IACG,cAAc,CAAE,IAAI,EAAE,MAAM,qBAAqB,EAAE,KAAK,EAAE,MAAM;IAStE;;;OAGG;IACG,mBAAmB;CA6B1B"}
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import { logger } from '@libp2p/logger';
|
|
2
|
+
import errCode from 'err-code';
|
|
3
|
+
import mergeOptions from 'merge-options';
|
|
4
|
+
import { LatencyMonitor } from './latency-monitor.js';
|
|
5
|
+
// @ts-expect-error retimer does not have types
|
|
6
|
+
import retimer from 'retimer';
|
|
7
|
+
import { CustomEvent, EventEmitter } from '@libp2p/interfaces';
|
|
8
|
+
import { trackedMap } from '@libp2p/tracked-map';
|
|
9
|
+
import { codes } from '../errors.js';
|
|
10
|
+
import { isPeerId } from '@libp2p/interfaces/peer-id';
|
|
11
|
+
// @ts-expect-error setMaxListeners is missing from the node 16 types
|
|
12
|
+
import { setMaxListeners } from 'events';
|
|
13
|
+
import * as STATUS from '@libp2p/interfaces/connection/status';
|
|
14
|
+
const log = logger('libp2p:connection-manager');
|
|
15
|
+
const defaultOptions = {
|
|
16
|
+
maxConnections: Infinity,
|
|
17
|
+
minConnections: 0,
|
|
18
|
+
maxData: Infinity,
|
|
19
|
+
maxSentData: Infinity,
|
|
20
|
+
maxReceivedData: Infinity,
|
|
21
|
+
maxEventLoopDelay: Infinity,
|
|
22
|
+
pollInterval: 2000,
|
|
23
|
+
autoDialInterval: 10000,
|
|
24
|
+
movingAverageInterval: 60000,
|
|
25
|
+
defaultPeerValue: 1
|
|
26
|
+
};
|
|
27
|
+
const METRICS_COMPONENT = 'connection-manager';
|
|
28
|
+
const METRICS_PEER_CONNECTIONS = 'peer-connections';
|
|
29
|
+
const METRICS_PEER_VALUES = 'peer-values';
|
|
30
|
+
/**
|
|
31
|
+
* Responsible for managing known connections.
|
|
32
|
+
*/
|
|
33
|
+
export class DefaultConnectionManager extends EventEmitter {
|
|
34
|
+
constructor(components, init = {}) {
|
|
35
|
+
super();
|
|
36
|
+
this.components = components;
|
|
37
|
+
this.init = mergeOptions.call({ ignoreUndefined: true }, defaultOptions, init);
|
|
38
|
+
if (this.init.maxConnections < this.init.minConnections) {
|
|
39
|
+
throw errCode(new Error('Connection Manager maxConnections must be greater than minConnections'), codes.ERR_INVALID_PARAMETERS);
|
|
40
|
+
}
|
|
41
|
+
log('options: %o', this.init);
|
|
42
|
+
/**
|
|
43
|
+
* Map of peer identifiers to their peer value for pruning connections.
|
|
44
|
+
*
|
|
45
|
+
* @type {Map<string, number>}
|
|
46
|
+
*/
|
|
47
|
+
this.peerValues = trackedMap({
|
|
48
|
+
component: METRICS_COMPONENT,
|
|
49
|
+
metric: METRICS_PEER_VALUES,
|
|
50
|
+
metrics: this.components.getMetrics()
|
|
51
|
+
});
|
|
52
|
+
/**
|
|
53
|
+
* Map of connections per peer
|
|
54
|
+
*/
|
|
55
|
+
this.connections = trackedMap({
|
|
56
|
+
component: METRICS_COMPONENT,
|
|
57
|
+
metric: METRICS_PEER_CONNECTIONS,
|
|
58
|
+
metrics: this.components.getMetrics()
|
|
59
|
+
});
|
|
60
|
+
this.started = false;
|
|
61
|
+
this._checkMetrics = this._checkMetrics.bind(this);
|
|
62
|
+
this.latencyMonitor = new LatencyMonitor({
|
|
63
|
+
latencyCheckIntervalMs: init.pollInterval,
|
|
64
|
+
dataEmitIntervalMs: init.pollInterval
|
|
65
|
+
});
|
|
66
|
+
try {
|
|
67
|
+
// This emitter gets listened to a lot
|
|
68
|
+
setMaxListeners?.(Infinity, this);
|
|
69
|
+
}
|
|
70
|
+
catch { }
|
|
71
|
+
this.components.getUpgrader().addEventListener('connection', (evt) => {
|
|
72
|
+
void this.onConnect(evt).catch(err => {
|
|
73
|
+
log.error(err);
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
this.components.getUpgrader().addEventListener('connectionEnd', this.onDisconnect.bind(this));
|
|
77
|
+
}
|
|
78
|
+
isStarted() {
|
|
79
|
+
return this.started;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Starts the Connection Manager. If Metrics are not enabled on libp2p
|
|
83
|
+
* only event loop and connection limits will be monitored.
|
|
84
|
+
*/
|
|
85
|
+
async start() {
|
|
86
|
+
if (this.components.getMetrics() != null) {
|
|
87
|
+
this.timer = this.timer ?? retimer(this._checkMetrics, this.init.pollInterval);
|
|
88
|
+
}
|
|
89
|
+
// latency monitor
|
|
90
|
+
this.latencyMonitor.start();
|
|
91
|
+
this._onLatencyMeasure = this._onLatencyMeasure.bind(this);
|
|
92
|
+
this.latencyMonitor.addEventListener('data', this._onLatencyMeasure);
|
|
93
|
+
this.started = true;
|
|
94
|
+
log('started');
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Stops the Connection Manager
|
|
98
|
+
*/
|
|
99
|
+
async stop() {
|
|
100
|
+
this.timer?.clear();
|
|
101
|
+
this.latencyMonitor.removeEventListener('data', this._onLatencyMeasure);
|
|
102
|
+
this.latencyMonitor.stop();
|
|
103
|
+
this.started = false;
|
|
104
|
+
await this._close();
|
|
105
|
+
log('stopped');
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Cleans up the connections
|
|
109
|
+
*/
|
|
110
|
+
async _close() {
|
|
111
|
+
// Close all connections we're tracking
|
|
112
|
+
const tasks = [];
|
|
113
|
+
for (const connectionList of this.connections.values()) {
|
|
114
|
+
for (const connection of connectionList) {
|
|
115
|
+
tasks.push(connection.close());
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
log('closing %d connections', tasks.length);
|
|
119
|
+
await Promise.all(tasks);
|
|
120
|
+
this.connections.clear();
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Sets the value of the given peer. Peers with lower values
|
|
124
|
+
* will be disconnected first.
|
|
125
|
+
*/
|
|
126
|
+
setPeerValue(peerId, value) {
|
|
127
|
+
if (value < 0 || value > 1) {
|
|
128
|
+
throw new Error('value should be a number between 0 and 1');
|
|
129
|
+
}
|
|
130
|
+
this.peerValues.set(peerId.toString(), value);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Checks the libp2p metrics to determine if any values have exceeded
|
|
134
|
+
* the configured maximums.
|
|
135
|
+
*
|
|
136
|
+
* @private
|
|
137
|
+
*/
|
|
138
|
+
async _checkMetrics() {
|
|
139
|
+
const metrics = this.components.getMetrics();
|
|
140
|
+
if (metrics != null) {
|
|
141
|
+
try {
|
|
142
|
+
const movingAverages = metrics.getGlobal().getMovingAverages();
|
|
143
|
+
const received = movingAverages.dataReceived[this.init.movingAverageInterval].movingAverage;
|
|
144
|
+
await this._checkMaxLimit('maxReceivedData', received);
|
|
145
|
+
const sent = movingAverages.dataSent[this.init.movingAverageInterval].movingAverage;
|
|
146
|
+
await this._checkMaxLimit('maxSentData', sent);
|
|
147
|
+
const total = received + sent;
|
|
148
|
+
await this._checkMaxLimit('maxData', total);
|
|
149
|
+
log('metrics update', total);
|
|
150
|
+
}
|
|
151
|
+
finally {
|
|
152
|
+
this.timer = retimer(this._checkMetrics, this.init.pollInterval);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Tracks the incoming connection and check the connection limit
|
|
158
|
+
*/
|
|
159
|
+
async onConnect(evt) {
|
|
160
|
+
const { detail: connection } = evt;
|
|
161
|
+
if (!this.started) {
|
|
162
|
+
// This can happen when we are in the process of shutting down the node
|
|
163
|
+
await connection.close();
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
const peerId = connection.remotePeer;
|
|
167
|
+
const peerIdStr = peerId.toString();
|
|
168
|
+
const storedConns = this.connections.get(peerIdStr);
|
|
169
|
+
this.dispatchEvent(new CustomEvent('peer:connect', { detail: connection }));
|
|
170
|
+
if (storedConns != null) {
|
|
171
|
+
storedConns.push(connection);
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
this.connections.set(peerIdStr, [connection]);
|
|
175
|
+
}
|
|
176
|
+
if (peerId.publicKey != null) {
|
|
177
|
+
await this.components.getPeerStore().keyBook.set(peerId, peerId.publicKey);
|
|
178
|
+
}
|
|
179
|
+
if (!this.peerValues.has(peerIdStr)) {
|
|
180
|
+
this.peerValues.set(peerIdStr, this.init.defaultPeerValue);
|
|
181
|
+
}
|
|
182
|
+
await this._checkMaxLimit('maxConnections', this.getConnectionList().length);
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Removes the connection from tracking
|
|
186
|
+
*/
|
|
187
|
+
onDisconnect(evt) {
|
|
188
|
+
const { detail: connection } = evt;
|
|
189
|
+
if (!this.started) {
|
|
190
|
+
// This can happen when we are in the process of shutting down the node
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
const peerId = connection.remotePeer.toString();
|
|
194
|
+
let storedConn = this.connections.get(peerId);
|
|
195
|
+
if (storedConn != null && storedConn.length > 1) {
|
|
196
|
+
storedConn = storedConn.filter((conn) => conn.id !== connection.id);
|
|
197
|
+
this.connections.set(peerId, storedConn);
|
|
198
|
+
}
|
|
199
|
+
else if (storedConn != null) {
|
|
200
|
+
this.connections.delete(peerId);
|
|
201
|
+
this.peerValues.delete(connection.remotePeer.toString());
|
|
202
|
+
this.dispatchEvent(new CustomEvent('peer:disconnect', { detail: connection }));
|
|
203
|
+
this.components.getMetrics()?.onPeerDisconnected(connection.remotePeer);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
getConnectionMap() {
|
|
207
|
+
return this.connections;
|
|
208
|
+
}
|
|
209
|
+
getConnectionList() {
|
|
210
|
+
let output = [];
|
|
211
|
+
for (const connections of this.connections.values()) {
|
|
212
|
+
output = output.concat(connections);
|
|
213
|
+
}
|
|
214
|
+
return output;
|
|
215
|
+
}
|
|
216
|
+
getConnections(peerId) {
|
|
217
|
+
return this.connections.get(peerId.toString()) ?? [];
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Get a connection with a peer
|
|
221
|
+
*/
|
|
222
|
+
getConnection(peerId) {
|
|
223
|
+
const connections = this.getAll(peerId);
|
|
224
|
+
if (connections.length > 0) {
|
|
225
|
+
return connections[0];
|
|
226
|
+
}
|
|
227
|
+
return undefined;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Get all open connections with a peer
|
|
231
|
+
*/
|
|
232
|
+
getAll(peerId) {
|
|
233
|
+
if (!isPeerId(peerId)) {
|
|
234
|
+
throw errCode(new Error('peerId must be an instance of peer-id'), codes.ERR_INVALID_PARAMETERS);
|
|
235
|
+
}
|
|
236
|
+
const id = peerId.toString();
|
|
237
|
+
const connections = this.connections.get(id);
|
|
238
|
+
// Return all open connections
|
|
239
|
+
if (connections != null) {
|
|
240
|
+
return connections.filter(connection => connection.stat.status === STATUS.OPEN);
|
|
241
|
+
}
|
|
242
|
+
return [];
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* If the event loop is slow, maybe close a connection
|
|
246
|
+
*/
|
|
247
|
+
_onLatencyMeasure(evt) {
|
|
248
|
+
const { detail: summary } = evt;
|
|
249
|
+
this._checkMaxLimit('maxEventLoopDelay', summary.avgMs)
|
|
250
|
+
.catch(err => {
|
|
251
|
+
log.error(err);
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* If the `value` of `name` has exceeded its limit, maybe close a connection
|
|
256
|
+
*/
|
|
257
|
+
async _checkMaxLimit(name, value) {
|
|
258
|
+
const limit = this.init[name];
|
|
259
|
+
log.trace('checking limit of %s. current value: %d of %d', name, value, limit);
|
|
260
|
+
if (value > limit) {
|
|
261
|
+
log('%s: limit exceeded: %p, %d', this.components.getPeerId(), name, value);
|
|
262
|
+
await this._maybeDisconnectOne();
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* If we have more connections than our maximum, close a connection
|
|
267
|
+
* to the lowest valued peer.
|
|
268
|
+
*/
|
|
269
|
+
async _maybeDisconnectOne() {
|
|
270
|
+
if (this.init.minConnections < this.connections.size) {
|
|
271
|
+
const peerValues = Array.from(new Map([...this.peerValues.entries()].sort((a, b) => a[1] - b[1])));
|
|
272
|
+
log('%p: sorted peer values: %j', this.components.getPeerId(), peerValues);
|
|
273
|
+
const disconnectPeer = peerValues[0];
|
|
274
|
+
if (disconnectPeer != null) {
|
|
275
|
+
const peerId = disconnectPeer[0];
|
|
276
|
+
log('%p: lowest value peer is %s', this.components.getPeerId(), peerId);
|
|
277
|
+
log('%p: closing a connection to %j', this.components.getPeerId(), peerId);
|
|
278
|
+
for (const connections of this.connections.values()) {
|
|
279
|
+
if (connections[0].remotePeer.toString() === peerId) {
|
|
280
|
+
void connections[0].close()
|
|
281
|
+
.catch(err => {
|
|
282
|
+
log.error(err);
|
|
283
|
+
});
|
|
284
|
+
// TODO: should not need to invoke this manually
|
|
285
|
+
this.onDisconnect(new CustomEvent('connectionEnd', {
|
|
286
|
+
detail: connections[0]
|
|
287
|
+
}));
|
|
288
|
+
break;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/connection-manager/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,OAAO,MAAM,UAAU,CAAA;AAC9B,OAAO,YAAY,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,cAAc,EAAiB,MAAM,sBAAsB,CAAA;AACpE,+CAA+C;AAC/C,OAAO,OAAO,MAAM,SAAS,CAAA;AAC7B,OAAO,EAAE,WAAW,EAAE,YAAY,EAAa,MAAM,oBAAoB,CAAA;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AACpC,OAAO,EAAE,QAAQ,EAAU,MAAM,4BAA4B,CAAA;AAC7D,qEAAqE;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA;AAIxC,OAAO,KAAK,MAAM,MAAM,sCAAsC,CAAA;AAE9D,MAAM,GAAG,GAAG,MAAM,CAAC,2BAA2B,CAAC,CAAA;AAE/C,MAAM,cAAc,GAAmC;IACrD,cAAc,EAAE,QAAQ;IACxB,cAAc,EAAE,CAAC;IACjB,OAAO,EAAE,QAAQ;IACjB,WAAW,EAAE,QAAQ;IACrB,eAAe,EAAE,QAAQ;IACzB,iBAA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