import { MapDef } from "@lodestar/utils";
/**
 * TODO GLOAS: Revisit this value and add rational for choosing it
 */
const SLOTS_RETAINED = 2;
/**
 * Tracks execution payload bids we've already seen per (slot, builder).
 */
export class SeenExecutionPayloadBids {
    builderIndexesBySlot = new MapDef(() => new Set());
    lowestPermissibleSlot = 0;
    isKnown(slot, builderIndex) {
        return this.builderIndexesBySlot.get(slot)?.has(builderIndex) === true;
    }
    add(slot, builderIndex) {
        if (slot < this.lowestPermissibleSlot) {
            throw Error(`slot ${slot} < lowestPermissibleSlot ${this.lowestPermissibleSlot}`);
        }
        this.builderIndexesBySlot.getOrDefault(slot).add(builderIndex);
    }
    prune(currentSlot) {
        this.lowestPermissibleSlot = Math.max(currentSlot - SLOTS_RETAINED, 0);
        for (const slot of this.builderIndexesBySlot.keys()) {
            if (slot < this.lowestPermissibleSlot) {
                this.builderIndexesBySlot.delete(slot);
            }
        }
    }
}
//# sourceMappingURL=seenExecutionPayloadBids.js.map