@waku/core 0.0.37-7a9850d.0 → 0.0.37-c7682ea.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundle/index.js +4745 -899
- package/bundle/lib/message/version_0.js +1 -1
- package/bundle/{version_0-9DPFjcJG.js → version_0-Bc0h7ah2.js} +312 -33
- package/dist/.tsbuildinfo +1 -1
- package/dist/lib/connection_manager/connection_limiter.d.ts +37 -0
- package/dist/lib/connection_manager/connection_limiter.js +124 -0
- package/dist/lib/connection_manager/connection_limiter.js.map +1 -0
- package/dist/lib/connection_manager/connection_manager.d.ts +20 -105
- package/dist/lib/connection_manager/connection_manager.js +83 -508
- package/dist/lib/connection_manager/connection_manager.js.map +1 -1
- package/dist/lib/connection_manager/dialer.d.ts +28 -0
- package/dist/lib/connection_manager/dialer.js +100 -0
- package/dist/lib/connection_manager/dialer.js.map +1 -0
- package/dist/lib/connection_manager/discovery_dialer.d.ts +26 -0
- package/dist/lib/connection_manager/discovery_dialer.js +68 -0
- package/dist/lib/connection_manager/discovery_dialer.js.map +1 -0
- package/dist/lib/connection_manager/keep_alive_manager.d.ts +17 -7
- package/dist/lib/connection_manager/keep_alive_manager.js +110 -74
- package/dist/lib/connection_manager/keep_alive_manager.js.map +1 -1
- package/dist/lib/connection_manager/network_monitor.d.ts +36 -0
- package/dist/lib/connection_manager/network_monitor.js +81 -0
- package/dist/lib/connection_manager/network_monitor.js.map +1 -0
- package/dist/lib/connection_manager/shard_reader.d.ts +28 -0
- package/dist/lib/connection_manager/shard_reader.js +70 -0
- package/dist/lib/connection_manager/shard_reader.js.map +1 -0
- package/dist/lib/connection_manager/utils.d.ts +16 -1
- package/dist/lib/connection_manager/utils.js +23 -0
- package/dist/lib/connection_manager/utils.js.map +1 -1
- package/dist/lib/filter/filter.d.ts +2 -3
- package/dist/lib/filter/filter.js +5 -25
- package/dist/lib/filter/filter.js.map +1 -1
- package/dist/lib/light_push/light_push.d.ts +2 -3
- package/dist/lib/light_push/light_push.js +1 -3
- package/dist/lib/light_push/light_push.js.map +1 -1
- package/package.json +1 -1
- package/src/lib/connection_manager/connection_limiter.ts +201 -0
- package/src/lib/connection_manager/connection_manager.ts +104 -669
- package/src/lib/connection_manager/dialer.ts +139 -0
- package/src/lib/connection_manager/discovery_dialer.ts +106 -0
- package/src/lib/connection_manager/keep_alive_manager.ts +154 -87
- package/src/lib/connection_manager/network_monitor.ts +112 -0
- package/src/lib/connection_manager/shard_reader.ts +134 -0
- package/src/lib/connection_manager/utils.ts +27 -1
- package/src/lib/filter/filter.ts +3 -28
- package/src/lib/light_push/light_push.ts +1 -5
@@ -1,119 +1,34 @@
|
|
1
|
-
import { type
|
1
|
+
import { type Peer, type PeerId, type Stream } from "@libp2p/interface";
|
2
2
|
import { MultiaddrInput } from "@multiformats/multiaddr";
|
3
|
-
import { ConnectionManagerOptions, IConnectionManager,
|
3
|
+
import { ConnectionManagerOptions, IConnectionManager, IRelay, IWakuEventEmitter, NetworkConfig, PubsubTopic } from "@waku/interfaces";
|
4
4
|
import { Libp2p } from "@waku/interfaces";
|
5
5
|
type ConnectionManagerConstructorOptions = {
|
6
6
|
libp2p: Libp2p;
|
7
|
+
events: IWakuEventEmitter;
|
7
8
|
pubsubTopics: PubsubTopic[];
|
9
|
+
networkConfig: NetworkConfig;
|
8
10
|
relay?: IRelay;
|
9
11
|
config?: Partial<ConnectionManagerOptions>;
|
10
12
|
};
|
11
|
-
export declare class ConnectionManager
|
12
|
-
readonly pubsubTopics
|
13
|
-
private keepAliveManager;
|
13
|
+
export declare class ConnectionManager implements IConnectionManager {
|
14
|
+
private readonly pubsubTopics;
|
15
|
+
private readonly keepAliveManager;
|
16
|
+
private readonly discoveryDialer;
|
17
|
+
private readonly dialer;
|
18
|
+
private readonly shardReader;
|
19
|
+
private readonly networkMonitor;
|
20
|
+
private readonly connectionLimiter;
|
14
21
|
private options;
|
15
22
|
private libp2p;
|
16
|
-
private dialAttemptsForPeer;
|
17
|
-
private dialErrorsForPeer;
|
18
|
-
private currentActiveParallelDialCount;
|
19
|
-
private pendingPeerDialQueue;
|
20
|
-
private isP2PNetworkConnected;
|
21
|
-
isConnected(): boolean;
|
22
|
-
stop(): void;
|
23
|
-
dropConnection(peerId: PeerId): Promise<void>;
|
24
|
-
getPeersByDiscovery(): Promise<PeersByDiscoveryResult>;
|
25
23
|
constructor(options: ConnectionManagerConstructorOptions);
|
24
|
+
start(): void;
|
25
|
+
stop(): void;
|
26
|
+
isConnected(): boolean;
|
27
|
+
dial(peer: PeerId | MultiaddrInput, protocolCodecs: string[]): Promise<Stream>;
|
28
|
+
hangUp(peer: PeerId | MultiaddrInput): Promise<boolean>;
|
26
29
|
getConnectedPeers(codec?: string): Promise<Peer[]>;
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
* Attempts to establish a connection with a peer and set up specified protocols.
|
31
|
-
* The method handles both PeerId and Multiaddr inputs, manages connection attempts,
|
32
|
-
* and maintains the connection state.
|
33
|
-
*
|
34
|
-
* The dialing process includes:
|
35
|
-
* 1. Converting input to dialable peer info
|
36
|
-
* 2. Managing parallel dial attempts
|
37
|
-
* 3. Attempting to establish protocol-specific connections
|
38
|
-
* 4. Handling connection failures and retries
|
39
|
-
* 5. Updating the peer store and connection state
|
40
|
-
*
|
41
|
-
* @param {PeerId | MultiaddrInput} peer - The peer to connect to, either as a PeerId or multiaddr
|
42
|
-
* @param {string[]} [protocolCodecs] - Optional array of protocol-specific codec strings to establish
|
43
|
-
* (e.g., for LightPush, Filter, Store protocols)
|
44
|
-
*
|
45
|
-
* @throws {Error} If the multiaddr is missing a peer ID
|
46
|
-
* @throws {Error} If the maximum dial attempts are reached and the peer cannot be dialed
|
47
|
-
* @throws {Error} If there's an error deleting an undialable peer from the peer store
|
48
|
-
*
|
49
|
-
* @example
|
50
|
-
* ```typescript
|
51
|
-
* // Dial using PeerId
|
52
|
-
* await connectionManager.dialPeer(peerId);
|
53
|
-
*
|
54
|
-
* // Dial using multiaddr with specific protocols
|
55
|
-
* await connectionManager.dialPeer(multiaddr, [
|
56
|
-
* "/vac/waku/relay/2.0.0",
|
57
|
-
* "/vac/waku/lightpush/2.0.0-beta1"
|
58
|
-
* ]);
|
59
|
-
* ```
|
60
|
-
*
|
61
|
-
* @remarks
|
62
|
-
* - The method implements exponential backoff through multiple dial attempts
|
63
|
-
* - Maintains a queue for parallel dial attempts (limited by maxParallelDials)
|
64
|
-
* - Integrates with the KeepAliveManager for connection maintenance
|
65
|
-
* - Updates the peer store and connection state after successful/failed attempts
|
66
|
-
* - If all dial attempts fail, triggers DNS discovery as a fallback
|
67
|
-
*/
|
68
|
-
dialPeer(peer: PeerId | MultiaddrInput): Promise<Connection>;
|
69
|
-
/**
|
70
|
-
* Dial a peer with specific protocols.
|
71
|
-
* This method is a raw proxy to the libp2p dialProtocol method.
|
72
|
-
* @param peer - The peer to connect to, either as a PeerId or multiaddr
|
73
|
-
* @param protocolCodecs - Optional array of protocol-specific codec strings to establish
|
74
|
-
* @returns A stream to the peer
|
75
|
-
*/
|
76
|
-
rawDialPeerWithProtocols(peer: PeerId | MultiaddrInput, protocolCodecs: string[]): Promise<Stream>;
|
77
|
-
/**
|
78
|
-
* Internal utility to extract a PeerId or Multiaddr from a peer input.
|
79
|
-
* This is used internally by the connection manager to handle different peer input formats.
|
80
|
-
* @internal
|
81
|
-
*/
|
82
|
-
private getDialablePeerInfo;
|
83
|
-
private attemptDnsDiscovery;
|
84
|
-
private processDialQueue;
|
85
|
-
private startPeerDiscoveryListener;
|
86
|
-
private startPeerConnectionListener;
|
87
|
-
private startPeerDisconnectionListener;
|
88
|
-
attemptDial(peerId: PeerId): Promise<void>;
|
89
|
-
private onEventHandlers;
|
90
|
-
/**
|
91
|
-
* Checks if the peer should be dialed based on the following conditions:
|
92
|
-
* 1. If the peer is already connected, don't dial
|
93
|
-
* 2. If the peer is not part of any of the configured pubsub topics, don't dial
|
94
|
-
* 3. If the peer is not dialable based on bootstrap status, don't dial
|
95
|
-
* 4. If the peer is already has an active dial attempt, or has been dialed before, don't dial it
|
96
|
-
* @returns true if the peer should be dialed, false otherwise
|
97
|
-
*/
|
98
|
-
private shouldDialPeer;
|
99
|
-
/**
|
100
|
-
* Checks if the peer is dialable based on the following conditions:
|
101
|
-
* 1. If the peer is a bootstrap peer, it is only dialable if the number of current bootstrap connections is less than the max allowed.
|
102
|
-
* 2. If the peer is not a bootstrap peer
|
103
|
-
*/
|
104
|
-
private isPeerDialableBasedOnBootstrapStatus;
|
105
|
-
private dispatchDiscoveryEvent;
|
106
|
-
/**
|
107
|
-
* Fetches the tag names for a given peer
|
108
|
-
*/
|
109
|
-
private getTagNamesForPeer;
|
110
|
-
isPeerOnSameShard(peerId: PeerId): Promise<boolean>;
|
111
|
-
isPeerOnPubsubTopic(peerId: PeerId, pubsubTopic: string): Promise<boolean>;
|
112
|
-
private getPeerShardInfo;
|
113
|
-
private startNetworkStatusListener;
|
114
|
-
private stopNetworkStatusListener;
|
115
|
-
private setP2PNetworkConnected;
|
116
|
-
private setP2PNetworkDisconnected;
|
117
|
-
private dispatchWakuConnectionEvent;
|
30
|
+
isTopicConfigured(pubsubTopic: PubsubTopic): boolean;
|
31
|
+
hasShardInfo(peerId: PeerId): Promise<boolean>;
|
32
|
+
isPeerOnTopic(peerId: PeerId, pubsubTopic: string): Promise<boolean>;
|
118
33
|
}
|
119
34
|
export {};
|