Skip to content

Commit

Permalink
Merge 197c50f into 384e393
Browse files Browse the repository at this point in the history
  • Loading branch information
twoeths committed Jul 29, 2022
2 parents 384e393 + 197c50f commit 8df4a5c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/beacon-node/src/network/gossip/encoding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {GossipTopicCache} from "./topic.js";
*/
export function fastMsgIdFn(rpcMsg: RPC.IMessage): string {
if (rpcMsg.data) {
return Buffer.from(digest(rpcMsg.data)).slice(0, 8).toString("hex");
return Buffer.from(digest(rpcMsg.data)).subarray(0, 8).toString("hex");
} else {
return "0000000000000000";
}
Expand Down Expand Up @@ -53,7 +53,7 @@ export function msgIdFn(gossipTopicCache: GossipTopicCache, msg: GossipsubMessag
}
}

return digest(Buffer.concat(vec)).slice(0, 20);
return Buffer.from(digest(Buffer.concat(vec))).subarray(0, 20);
}

export class DataTransformSnappy {
Expand Down
4 changes: 2 additions & 2 deletions packages/beacon-node/src/util/multifork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ export function getSignedBlockTypeFromBytes(
}

export function getSlotFromBytes(bytes: Buffer | Uint8Array): Slot {
return bytesToInt(bytes.slice(SLOT_BYTES_POSITION_IN_BLOCK, SLOT_BYTES_POSITION_IN_BLOCK + SLOT_BYTE_COUNT));
return bytesToInt(bytes.subarray(SLOT_BYTES_POSITION_IN_BLOCK, SLOT_BYTES_POSITION_IN_BLOCK + SLOT_BYTE_COUNT));
}

export function getStateTypeFromBytes(
config: IChainForkConfig,
bytes: Buffer | Uint8Array
): allForks.AllForksSSZTypes["BeaconState"] {
const slot = bytesToInt(bytes.slice(SLOT_BYTES_POSITION_IN_STATE, SLOT_BYTES_POSITION_IN_STATE + SLOT_BYTE_COUNT));
const slot = bytesToInt(bytes.subarray(SLOT_BYTES_POSITION_IN_STATE, SLOT_BYTES_POSITION_IN_STATE + SLOT_BYTE_COUNT));
return config.getForkTypes(slot).BeaconState;
}

0 comments on commit 8df4a5c

Please sign in to comment.