@waku/core 0.0.29-fd60cc2.0 → 0.0.30-00c77c6.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/CHANGELOG.md +33 -0
- package/bundle/{base_protocol-B8NGoK0E.js → base_protocol-kugTP2Op.js} +2 -2
- package/bundle/{browser-DoQRY-an.js → browser-B9234RhB.js} +5 -0
- package/bundle/{index-DBP1NHED.js → index-egXdK_Fb.js} +6 -14
- package/bundle/index.js +160 -371
- package/bundle/lib/base_protocol.js +3 -3
- package/bundle/lib/message/version_0.js +3 -3
- package/bundle/lib/predefined_bootstrap_nodes.js +1 -1
- package/bundle/{version_0-B6lI5jri.js → version_0-BoLZMvhu.js} +3 -3
- package/dist/.tsbuildinfo +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/filter/index.d.ts +13 -2
- package/dist/lib/filter/index.js +151 -273
- package/dist/lib/filter/index.js.map +1 -1
- package/dist/lib/keep_alive_manager.js +1 -1
- package/dist/lib/light_push/index.d.ts +3 -4
- package/dist/lib/light_push/index.js.map +1 -1
- package/dist/lib/metadata/index.js.map +1 -1
- package/dist/lib/wait_for_remote_peer.js +1 -1
- package/dist/lib/wait_for_remote_peer.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -1
- package/src/lib/filter/index.ts +223 -481
- package/src/lib/keep_alive_manager.ts +1 -1
- package/src/lib/light_push/index.ts +10 -12
- package/src/lib/metadata/index.ts +6 -4
- package/src/lib/wait_for_remote_peer.ts +1 -1
@@ -1,13 +1,13 @@
|
|
1
|
-
import type { Peer,
|
1
|
+
import type { Peer, Stream } from "@libp2p/interface";
|
2
2
|
import {
|
3
|
-
|
4
|
-
IBaseProtocolCore,
|
5
|
-
IEncoder,
|
6
|
-
IMessage,
|
7
|
-
Libp2p,
|
8
|
-
ProtocolCreateOptions,
|
3
|
+
type CoreProtocolResult,
|
4
|
+
type IBaseProtocolCore,
|
5
|
+
type IEncoder,
|
6
|
+
type IMessage,
|
7
|
+
type Libp2p,
|
8
|
+
type ProtocolCreateOptions,
|
9
9
|
ProtocolError,
|
10
|
-
|
10
|
+
type ThisOrThat
|
11
11
|
} from "@waku/interfaces";
|
12
12
|
import { PushResponse } from "@waku/proto";
|
13
13
|
import { isMessageSizeUnderCap } from "@waku/utils";
|
@@ -26,9 +26,7 @@ const log = new Logger("light-push");
|
|
26
26
|
export const LightPushCodec = "/vac/waku/lightpush/2.0.0-beta1";
|
27
27
|
export { PushResponse };
|
28
28
|
|
29
|
-
type PreparePushMessageResult =
|
30
|
-
|
31
|
-
type CoreSendResult = ProtocolResult<"success", PeerId, "failure", Failure>;
|
29
|
+
type PreparePushMessageResult = ThisOrThat<"query", PushRpc>;
|
32
30
|
|
33
31
|
/**
|
34
32
|
* Implements the [Waku v2 Light Push protocol](https://rfc.vac.dev/spec/19/).
|
@@ -84,7 +82,7 @@ export class LightPushCore extends BaseProtocol implements IBaseProtocolCore {
|
|
84
82
|
encoder: IEncoder,
|
85
83
|
message: IMessage,
|
86
84
|
peer: Peer
|
87
|
-
): Promise<
|
85
|
+
): Promise<CoreProtocolResult> {
|
88
86
|
const { query, error: preparationError } = await this.preparePushMessage(
|
89
87
|
encoder,
|
90
88
|
message
|
@@ -3,9 +3,9 @@ import { IncomingStreamData } from "@libp2p/interface";
|
|
3
3
|
import {
|
4
4
|
type IMetadata,
|
5
5
|
type Libp2pComponents,
|
6
|
+
type MetadataQueryResult,
|
6
7
|
type PeerIdStr,
|
7
8
|
ProtocolError,
|
8
|
-
QueryResult,
|
9
9
|
type ShardInfo
|
10
10
|
} from "@waku/interfaces";
|
11
11
|
import { proto_metadata } from "@waku/proto";
|
@@ -74,7 +74,7 @@ class Metadata extends BaseProtocol implements IMetadata {
|
|
74
74
|
/**
|
75
75
|
* Make a metadata query to a peer
|
76
76
|
*/
|
77
|
-
async query(peerId: PeerId): Promise<
|
77
|
+
async query(peerId: PeerId): Promise<MetadataQueryResult> {
|
78
78
|
const request = proto_metadata.WakuMetadataRequest.encode(this.shardInfo);
|
79
79
|
|
80
80
|
const peer = await this.peerStore.get(peerId);
|
@@ -112,7 +112,9 @@ class Metadata extends BaseProtocol implements IMetadata {
|
|
112
112
|
};
|
113
113
|
}
|
114
114
|
|
115
|
-
public async confirmOrAttemptHandshake(
|
115
|
+
public async confirmOrAttemptHandshake(
|
116
|
+
peerId: PeerId
|
117
|
+
): Promise<MetadataQueryResult> {
|
116
118
|
const shardInfo = this.handshakesConfirmed.get(peerId.toString());
|
117
119
|
if (shardInfo) {
|
118
120
|
return {
|
@@ -126,7 +128,7 @@ class Metadata extends BaseProtocol implements IMetadata {
|
|
126
128
|
|
127
129
|
private decodeMetadataResponse(
|
128
130
|
encodedResponse: Uint8ArrayList[]
|
129
|
-
):
|
131
|
+
): MetadataQueryResult {
|
130
132
|
const bytes = new Uint8ArrayList();
|
131
133
|
|
132
134
|
encodedResponse.forEach((chunk) => {
|
@@ -70,7 +70,7 @@ export async function waitForRemotePeer(
|
|
70
70
|
if (!waku.filter)
|
71
71
|
throw new Error("Cannot wait for Filter peer: protocol not mounted");
|
72
72
|
promises.push(
|
73
|
-
waitForConnectedPeer(waku.filter, waku.libp2p.services.metadata)
|
73
|
+
waitForConnectedPeer(waku.filter.protocol, waku.libp2p.services.metadata)
|
74
74
|
);
|
75
75
|
}
|
76
76
|
|