@waku/discovery
Version:
Contains various discovery mechanisms: DNS Discovery (EIP-1459, Peer Exchange, Local Peer Cache Discovery.
41 lines • 1.05 kB
JavaScript
import { proto_peer_exchange as proto } from "@waku/proto";
/**
* PeerExchangeRPC represents a message conforming to the Waku Peer Exchange protocol
*/
export class PeerExchangeRPC {
proto;
constructor(proto) {
this.proto = proto;
}
static createRequest(params) {
const { numPeers } = params;
return new PeerExchangeRPC({
query: {
numPeers: numPeers
},
response: undefined
});
}
/**
* Encode the current PeerExchangeRPC request to bytes
* @returns Uint8Array
*/
encode() {
return proto.PeerExchangeRPC.encode(this.proto);
}
/**
* Decode the current PeerExchangeRPC request to bytes
* @returns Uint8Array
*/
static decode(bytes) {
const res = proto.PeerExchangeRPC.decode(bytes);
return new PeerExchangeRPC(res);
}
get query() {
return this.proto.query;
}
get response() {
return this.proto.response;
}
}
//# sourceMappingURL=rpc.js.map