mirror of
https://github.com/logos-messaging/logos-messaging-js.git
synced 2026-01-16 15:03:10 +00:00
* wip -- yet to test * update: draft * wip * support passing flags manually to nwaku node * refactor peer-exchange test * switch response from uint8array to ENR * rm: unnecesary logs * implement clas * fix: for loop * init-wip: directories * setup: new package & fix circular deps * bind a response handler * wip: refactor & update test * test logs * wip code - debugging * address: comments * Update packages/core/src/lib/waku_peer_exchange/peer_discovery.ts Co-authored-by: fryorcraken.eth <110212804+fryorcraken@users.noreply.github.com> * Update packages/core/src/lib/waku_peer_exchange/peer_discovery.ts Co-authored-by: fryorcraken.eth <110212804+fryorcraken@users.noreply.github.com> * address: comments * address: comments * address: comments * address: comments * address: comments * fix: test build * refactor * fix: build * comply with API * numPeers: use number instead of bigint * fix: build * Update packages/peer-exchange/package.json Co-authored-by: fryorcraken.eth <110212804+fryorcraken@users.noreply.github.com> * Update packages/peer-exchange/src/waku_peer_exchange.ts Co-authored-by: fryorcraken.eth <110212804+fryorcraken@users.noreply.github.com> * Update packages/peer-exchange/src/waku_peer_exchange.ts Co-authored-by: fryorcraken.eth <110212804+fryorcraken@users.noreply.github.com> * Update packages/peer-exchange/src/waku_peer_exchange.ts Co-authored-by: fryorcraken.eth <110212804+fryorcraken@users.noreply.github.com> * address: comments, add eslint config * Update packages/peer-exchange/.eslintrc.cjs Co-authored-by: fryorcraken.eth <110212804+fryorcraken@users.noreply.github.com> * Update packages/peer-exchange/src/index.ts Co-authored-by: fryorcraken.eth <110212804+fryorcraken@users.noreply.github.com> * address comments * test works with test fleet * rm: only for px test => run all tests * fix: tests * reorder packages for build, and fix imports * remove: px test doesnt work with local nodes * chore: move proto into a separate package * fix: proto dir * fix: build * fix: ci * add: index for proto * fix: ci * Update packages/proto/package.json Co-authored-by: fryorcraken.eth <110212804+fryorcraken@users.noreply.github.com> * address comments * chore: run failing test with higher timeout * chore: run failing test with higher timeout * fix: ci Co-authored-by: fryorcraken.eth <110212804+fryorcraken@users.noreply.github.com>
45 lines
1.1 KiB
TypeScript
45 lines
1.1 KiB
TypeScript
import { proto_peer_exchange as proto } from "@waku/proto";
|
|
import { Uint8ArrayList } from "uint8arraylist";
|
|
|
|
/**
|
|
* PeerExchangeRPC represents a message conforming to the Waku Peer Exchange protocol
|
|
*/
|
|
export class PeerExchangeRPC {
|
|
public constructor(public proto: proto.PeerExchangeRPC) {}
|
|
|
|
static createRequest(params: proto.PeerExchangeQuery): PeerExchangeRPC {
|
|
const { numPeers } = params;
|
|
return new PeerExchangeRPC({
|
|
query: {
|
|
numPeers: numPeers,
|
|
},
|
|
response: undefined,
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Encode the current PeerExchangeRPC request to bytes
|
|
* @returns Uint8Array
|
|
*/
|
|
encode(): Uint8Array {
|
|
return proto.PeerExchangeRPC.encode(this.proto);
|
|
}
|
|
|
|
/**
|
|
* Decode the current PeerExchangeRPC request to bytes
|
|
* @returns Uint8Array
|
|
*/
|
|
static decode(bytes: Uint8ArrayList): PeerExchangeRPC {
|
|
const res = proto.PeerExchangeRPC.decode(bytes);
|
|
return new PeerExchangeRPC(res);
|
|
}
|
|
|
|
get query(): proto.PeerExchangeQuery | undefined {
|
|
return this.proto.query;
|
|
}
|
|
|
|
get response(): proto.PeerExchangeResponse | undefined {
|
|
return this.proto.response;
|
|
}
|
|
}
|