import { type Hash } from '@ariestools/sdk';
import type { ArchivistInstance } from '@xyo-network/sdk';
import type { MempoolViewer, PendingTransactionsOptions, SignedHydratedBlockWithHashMeta, SignedHydratedTransactionWithHashMeta, WindowedBlockViewer } from '@xyo-network/xl1-protocol/protocol-lib';
import type { ArchivistConnectionBinding } from '../../Archivists/index.js';
import type { CreatableProviderParams } from '../../CreatableProvider/index.js';
import { AbstractCreatableProvider } from '../../CreatableProvider/index.js';
/** Per-bundle handout statistics used to demote transactions that producers keep rejecting. */
export interface HandoutStats {
    firstHandoutAt: number;
    handouts: number;
}
/** Parameters for SimpleMempoolViewer. */
export interface SimpleMempoolViewerParams extends CreatableProviderParams {
    /** Connection the mempool stores self-provision from when archivists are not injected. */
    connection?: ArchivistConnectionBinding;
    /** Number of handouts before a transaction is considered demoted. Defaults to 3. */
    demotionThreshold?: number;
    /** External mempool viewers (reserved for future use). */
    externalMempools?: MempoolViewer[];
    /** Maximum age (in blocks) of a handout-stats entry before it is garbage collected. Defaults to 1000. */
    handoutStatsTtlBlocks?: number;
    /** Maximum fraction (0–1) of mempool inclusion candidates to return. Defaults to 0.66. */
    mempoolSelectionRatio?: number;
    pendingBlocksArchivist?: ArchivistInstance;
    pendingTransactionsArchivist?: ArchivistInstance;
}
/** SimpleMempoolViewer implementation. */
export declare class SimpleMempoolViewer extends AbstractCreatableProvider<SimpleMempoolViewerParams> implements MempoolViewer {
    static readonly connectionTypes: readonly ["lmdb", "mongo", "memory"];
    static readonly defaultMoniker: "MempoolViewer";
    static readonly dependencies: "WindowedBlockViewer"[];
    static readonly monikers: "MempoolViewer"[];
    static readonly surface: "node";
    moniker: "MempoolViewer";
    private _handoutStats;
    private _windowedBlockViewer?;
    protected get demotionThreshold(): number;
    protected get handoutStatsTtlBlocks(): number;
    protected get pendingBlocksArchivist(): ArchivistInstance;
    protected get pendingTransactionsArchivist(): ArchivistInstance;
    protected get windowedBlockViewer(): WindowedBlockViewer<"WindowedBlockViewer">;
    static paramsHandler(params: Partial<SimpleMempoolViewerParams>): Promise<SimpleMempoolViewerParams>;
    createHandler(): Promise<void>;
    /** Drop handout stats for the given bundle hashes. Called when a bundle has been evicted or otherwise removed from the pool. */
    forget(bundleHashes: Hash[]): void;
    /** Return the subset of the given bundle hashes that are currently considered demoted. */
    getDemotedBundleHashes(bundleHashes: Hash[]): Hash[];
    /**
     * Return the bundle hashes in the order they should be evicted under size pressure.
     * Demoted entries come first, sorted by handouts descending; the remainder is left as-is
     * so the caller can append by FIFO sequence order.
     */
    getEvictionPriorityOrder(bundleHashes: Hash[]): Hash[];
    getHandoutStats(bundleHash: Hash): HandoutStats | undefined;
    pendingBlocks({ cursor: providedCursor }?: PendingTransactionsOptions): Promise<SignedHydratedBlockWithHashMeta[]>;
    pendingTransactions({ cursor: providedCursor, limit, }?: PendingTransactionsOptions): Promise<SignedHydratedTransactionWithHashMeta[]>;
    protected isDemoted(bundleHash: Hash): boolean;
    private deleteBundledTransaction;
    private filterInclusionCandidates;
    private gcHandoutStats;
    private hydratePendingBundles;
    /**
     * Evaluates a transaction to determine if it should be purged from the mempool.
     * @param tx The transaction to evaluate
     * @param currentBlock The current block to use for evaluation
     * @returns True if the transaction should be purged, false otherwise
     */
    private isDeletable;
    /**
     * Evaluates a transaction to determine if is valid for inclusion in the next block. A transaction is invalid if:
     * - The transaction is too early/expired
     * - The transaction has already been included in a block
     * @param tx The transaction to evaluate
     * @param currentBlock The current block to use for evaluation
     * @param checkForDeletable Whether to check if the transaction is deletable (default: true)
     * @returns True if the transaction is valid for inclusion in the next block, false otherwise
     */
    private isInclusionCandidate;
    private recordHandout;
    private selectWithRatio;
}
//# sourceMappingURL=SimpleMempoolViewer.d.ts.map