UNPKG

@lodestar/beacon-node

Version:

A Typescript implementation of the beacon chain

23 lines 1.05 kB
import { encodeKey } from "@lodestar/db"; import { intToBytes } from "@lodestar/utils"; import { Bucket } from "../buckets.js"; export async function storeRootIndex(db, slot, blockRoot) { return db.put(getRootIndexKey(blockRoot), intToBytes(slot, 8, "be")); } export async function storeParentRootIndex(db, slot, parentRoot) { return db.put(getParentRootIndexKey(parentRoot), intToBytes(slot, 8, "be")); } export async function deleteRootIndex(db, signedBeaconBlockType, block) { const beaconBlockType = signedBeaconBlockType.fields.message; return db.delete(getRootIndexKey(beaconBlockType.hashTreeRoot(block.message))); } export async function deleteParentRootIndex(db, block) { return db.delete(getParentRootIndexKey(block.message.parentRoot)); } export function getParentRootIndexKey(parentRoot) { return encodeKey(Bucket.index_blockArchiveParentRootIndex, parentRoot); } export function getRootIndexKey(root) { return encodeKey(Bucket.index_blockArchiveRootIndex, root); } //# sourceMappingURL=blockArchiveIndex.js.map