Skip to content

Commit

Permalink
chore: consistent naming
Browse files Browse the repository at this point in the history
  • Loading branch information
wemeetagain committed Aug 18, 2023
1 parent e1f1a43 commit d387df6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions packages/reqresp/src/encodingStrategies/sszSnappy/decode.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions packages/reqresp/src/encodingStrategies/sszSnappy/encode.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {encode} from "uint8-varint";
import {encode as varintEncode} from "uint8-varint";
import {encodeSnappy} from "./snappyFrames/compress.js";

/**
Expand All @@ -15,7 +15,7 @@ export const writeSszSnappyPayload = encodeSszSnappy as (bytes: Uint8Array) => A
*/
export async function* encodeSszSnappy(bytes: Buffer): AsyncGenerator<Buffer> {
// 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
Expand Down

0 comments on commit d387df6

Please sign in to comment.