From 89de2e3c775e00f4448a1d583ecc9941f6df471a Mon Sep 17 00:00:00 2001 From: Franck Royer Date: Fri, 20 May 2022 10:28:05 +1000 Subject: [PATCH] Remove `buf` variable --- src/lib/waku_message/version_1.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/lib/waku_message/version_1.ts b/src/lib/waku_message/version_1.ts index aa533e6e96..3a3bc82e45 100644 --- a/src/lib/waku_message/version_1.ts +++ b/src/lib/waku_message/version_1.ts @@ -87,18 +87,16 @@ export async function clearEncode( export function clearDecode( message: Uint8Array | Buffer ): { payload: Uint8Array; sig?: Signature } | undefined { - const buf = Buffer.from(message); - let start = 1; - let sig; - const sizeOfPayloadSizeField = getSizeOfPayloadSizeField(message); if (sizeOfPayloadSizeField === 0) return; const payloadSize = getPayloadSize(message, sizeOfPayloadSizeField); - start += sizeOfPayloadSizeField; - const payload = buf.slice(start, start + payloadSize); + const payloadStart = 1 + sizeOfPayloadSizeField; + const payload = message.slice(payloadStart, payloadStart + payloadSize); const isSigned = isMessageSigned(message); + + let sig; if (isSigned) { const signature = getSignature(message); const hash = getHash(message, isSigned);