From d387df607903e9f610453af8b387793b99518353 Mon Sep 17 00:00:00 2001 From: Cayman Date: Fri, 18 Aug 2023 11:30:47 -0400 Subject: [PATCH] chore: consistent naming --- packages/reqresp/src/encodingStrategies/sszSnappy/decode.ts | 6 +++--- packages/reqresp/src/encodingStrategies/sszSnappy/encode.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/reqresp/src/encodingStrategies/sszSnappy/decode.ts b/packages/reqresp/src/encodingStrategies/sszSnappy/decode.ts index 14f96c0dbc2f..1bf9fc815e28 100644 --- a/packages/reqresp/src/encodingStrategies/sszSnappy/decode.ts +++ b/packages/reqresp/src/encodingStrategies/sszSnappy/decode.ts @@ -1,4 +1,4 @@ -import {decode, encodingLength} from "uint8-varint"; +import {decode as varintDecode, encodingLength as varintEncodingLength} from "uint8-varint"; import {Uint8ArrayList} from "uint8arraylist"; import {BufferedSource} from "../../utils/index.js"; import {TypeSizes} from "../../types.js"; @@ -34,14 +34,14 @@ export async function readSszSnappyHeader(bufferedSource: BufferedSource, type: let sszDataLength: number; try { - sszDataLength = decode(buffer.subarray()); + sszDataLength = varintDecode(buffer.subarray()); } catch (e) { throw new SszSnappyError({code: SszSnappyErrorCode.INVALID_VARINT_BYTES_COUNT, bytes: Infinity}); } // MUST validate: the unsigned protobuf varint used for the length-prefix MUST not be longer than 10 bytes // encodingLength function only returns 1-8 inclusive - const varintBytes = encodingLength(sszDataLength); + const varintBytes = varintEncodingLength(sszDataLength); buffer.consume(varintBytes); // MUST validate: the length-prefix is within the expected size bounds derived from the payload SSZ type. diff --git a/packages/reqresp/src/encodingStrategies/sszSnappy/encode.ts b/packages/reqresp/src/encodingStrategies/sszSnappy/encode.ts index 8c37a4fa0210..930aa242766d 100644 --- a/packages/reqresp/src/encodingStrategies/sszSnappy/encode.ts +++ b/packages/reqresp/src/encodingStrategies/sszSnappy/encode.ts @@ -1,4 +1,4 @@ -import {encode} from "uint8-varint"; +import {encode as varintEncode} from "uint8-varint"; import {encodeSnappy} from "./snappyFrames/compress.js"; /** @@ -15,7 +15,7 @@ export const writeSszSnappyPayload = encodeSszSnappy as (bytes: Uint8Array) => A */ export async function* encodeSszSnappy(bytes: Buffer): AsyncGenerator { // MUST encode the length of the raw SSZ bytes, encoded as an unsigned protobuf varint - yield Buffer.from(encode(bytes.length)); + yield Buffer.from(varintEncode(bytes.length)); // By first computing and writing the SSZ byte length, the SSZ encoder can then directly // write the chunk contents to the stream. Snappy writer compresses frame by frame