diff --git a/packages/portalnetwork/src/client/client.ts b/packages/portalnetwork/src/client/client.ts index f1e372ccd..af08fd983 100644 --- a/packages/portalnetwork/src/client/client.ts +++ b/packages/portalnetwork/src/client/client.ts @@ -450,9 +450,9 @@ export class PortalNetwork extends (EventEmitter as { new (): PortalNetworkEvent /** * * @param dstId `NodeId` of message recipient - * @param payload `Buffer` serialized payload of message + * @param payload `Uint8Array` serialized payload of message * @param networkId subnetwork ID of subnetwork message is being sent on - * @returns response from `dstId` as `Buffer` or null `Buffer` + * @returns response from `dstId` as `Uint8Array` or empty array */ public sendPortalNetworkMessage = async ( enr: ENR | string, diff --git a/packages/portalnetwork/src/networks/network.ts b/packages/portalnetwork/src/networks/network.ts index dfad0e163..d2828f256 100644 --- a/packages/portalnetwork/src/networks/network.ts +++ b/packages/portalnetwork/src/networks/network.ts @@ -93,6 +93,14 @@ export abstract class BaseNetwork extends EventEmitter { async handleNewRequest(request: INewRequest): Promise { return this.portal.uTP.handleNewRequest(request) } + + /** + * Send a properly formatted Portal Network message to another node + * @param dstId `NodeId` of message recipient + * @param payload `Uint8Array` serialized payload of message + * @param networkId subnetwork ID of subnetwork message is being sent on + * @returns response from `dstId` as `Buffer` or null `Buffer` + */ async sendMessage( enr: ENR | string, payload: Uint8Array, @@ -101,6 +109,7 @@ export abstract class BaseNetwork extends EventEmitter { ): Promise { return this.portal.sendPortalNetworkMessage(enr, payload, networkId, utpMessage) } + sendResponse(src: INodeAddress, requestId: bigint, payload: Uint8Array): Promise { return this.portal.sendPortalNetworkResponse(src, requestId, payload) }