@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.
@@ -56,7 +56,7 @@ export class KeepAliveManager {
56
56
  }
57
57
 
58
58
  try {
59
- await peerStore.patch(peerId, {
59
+ await peerStore.merge(peerId, {
60
60
  metadata: {
61
61
  ping: utf8ToBytes(ping.toString())
62
62
  }
@@ -1,13 +1,13 @@
1
- import type { Peer, PeerId, Stream } from "@libp2p/interface";
1
+ import type { Peer, Stream } from "@libp2p/interface";
2
2
  import {
3
- Failure,
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
- ProtocolResult
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 = ProtocolResult<"query", PushRpc>;
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<CoreSendResult> {
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<QueryResult> {
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(peerId: PeerId): Promise<QueryResult> {
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
- ): QueryResult {
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