mirror of https://github.com/waku-org/js-waku.git
Remove `buf` variable
This commit is contained in:
parent
06b4ab581d
commit
89de2e3c77
|
@ -87,18 +87,16 @@ export async function clearEncode(
|
||||||
export function clearDecode(
|
export function clearDecode(
|
||||||
message: Uint8Array | Buffer
|
message: Uint8Array | Buffer
|
||||||
): { payload: Uint8Array; sig?: Signature } | undefined {
|
): { payload: Uint8Array; sig?: Signature } | undefined {
|
||||||
const buf = Buffer.from(message);
|
|
||||||
let start = 1;
|
|
||||||
let sig;
|
|
||||||
|
|
||||||
const sizeOfPayloadSizeField = getSizeOfPayloadSizeField(message);
|
const sizeOfPayloadSizeField = getSizeOfPayloadSizeField(message);
|
||||||
if (sizeOfPayloadSizeField === 0) return;
|
if (sizeOfPayloadSizeField === 0) return;
|
||||||
|
|
||||||
const payloadSize = getPayloadSize(message, sizeOfPayloadSizeField);
|
const payloadSize = getPayloadSize(message, sizeOfPayloadSizeField);
|
||||||
start += sizeOfPayloadSizeField;
|
const payloadStart = 1 + sizeOfPayloadSizeField;
|
||||||
const payload = buf.slice(start, start + payloadSize);
|
const payload = message.slice(payloadStart, payloadStart + payloadSize);
|
||||||
|
|
||||||
const isSigned = isMessageSigned(message);
|
const isSigned = isMessageSigned(message);
|
||||||
|
|
||||||
|
let sig;
|
||||||
if (isSigned) {
|
if (isSigned) {
|
||||||
const signature = getSignature(message);
|
const signature = getSignature(message);
|
||||||
const hash = getHash(message, isSigned);
|
const hash = getHash(message, isSigned);
|
||||||
|
|
Loading…
Reference in New Issue