UNPKG

@lodestar/beacon-node

Version:

A Typescript implementation of the beacon chain

26 lines 928 B
import { Repository } from "@lodestar/db"; import { ssz } from "@lodestar/types"; import { bytesToInt } from "@lodestar/utils"; import { Bucket, getBucketNameByValue } from "../buckets.js"; export class Eth1DataRepository extends Repository { constructor(config, db) { const bucket = Bucket.phase0_eth1Data; super(config, db, bucket, ssz.phase0.Eth1DataOrdered, getBucketNameByValue(bucket)); } decodeKey(data) { return bytesToInt(super.decodeKey(data), "be"); } getId(_value) { throw new Error("Unable to create timestamp from block hash"); } async batchPutValues(eth1Datas) { await this.batchPut(eth1Datas.map((eth1Data) => ({ key: eth1Data.timestamp, value: eth1Data, }))); } async deleteOld(timestamp) { await this.batchDelete(await this.keys({ lt: timestamp })); } } //# sourceMappingURL=eth1Data.js.map