import { Repository } from "@lodestar/db";
import { ssz } from "@lodestar/types";
import { getLightClientHeaderTypeFromBytes } from "../../util/multifork.js";
import { Bucket, getBucketNameByValue } from "../buckets.js";
/**
 * Block headers by block root. Until finality includes all headers seen by this node. After finality,
 * all non-checkpoint headers are pruned from this repository.
 *
 * Used to prepare light client updates
 */
export class CheckpointHeaderRepository extends Repository {
    constructor(config, db) {
        // Pick some type but won't be used
        const bucket = Bucket.lightClient_checkpointHeader;
        super(config, db, bucket, ssz.altair.LightClientHeader, getBucketNameByValue(bucket));
    }
    // Overrides for multi-fork
    encodeValue(value) {
        return this.config.getPostAltairForkTypes(value.beacon.slot).LightClientHeader.serialize(value);
    }
    decodeValue(data) {
        return getLightClientHeaderTypeFromBytes(this.config, data).deserialize(data);
    }
    getId(value) {
        return this.config.getPostAltairForkTypes(value.beacon.slot).LightClientHeader.hashTreeRoot(value);
    }
}
//# sourceMappingURL=lightclientCheckpointHeader.js.map