import { saveDepths as e } from "../../../constants/save-depths.mjs";
import { AbstractSolanaEventService as t } from "./AbstractSolanaEventService.mjs";
//#region libs/shared/common/src/data-structures/event-service/solana/AbstractSolanaSnapshotService.ts
var n = class extends t {
	savedLatestSlot = 0;
	constructor(e, t) {
		super(e, t);
	}
	async init() {
		await this.loadSnapshot();
	}
	async retrieveEventsFromLatestBlock() {
		await this.solanaBlockchainEventEmitter.retrieveEvents(this.latestBlockNumber);
	}
	async loadSnapshot() {
		let e = await this.fetchSnapshot(), t = this.deserializeSnapshot(e);
		this.populateSnapshot(t), this.solanaBlockchainEventEmitter.syncFromAtMost(t.latestBlockNumber), this.savedLatestSlot = t.latestBlockNumber;
	}
	saveSnapshot() {
		return this.savedLatestSlot = this.latestBlockNumber, this.persistSnapshot(this.serializeSnapshot({
			latestBlockNumber: this.latestBlockNumber,
			payload: this.getSnapshotPayload()
		}));
	}
	async afterEventsAccepted(t) {
		(t > 0 || this.savedLatestSlot + e[this.chainId] < this.latestBlockNumber) && await this.saveSnapshot();
	}
};
//#endregion
export { n as AbstractSolanaSnapshotService };
