import type { Client } from "@keetanetwork/keetanet-client";
import type { Logger } from "./log/index.js";
import type { Block, BlockHash } from "@keetanetwork/keetanet-client/lib/block/index.js";
import type { BlockOperations } from "@keetanetwork/keetanet-client/lib/block/operations.js";
import { KeetaAnchorQueueRunner } from "./queue/index.js";
import type { KeetaAnchorQueueEntryExtra, KeetaAnchorQueueRequestID } from "./queue/index.js";
import type { JSONSerializable } from "./utils/json.js";
import type { KeetaAnchorQueueRunOptions } from "./queue/common.js";
interface BlockListenerConfig {
    client: Client;
    logger?: Logger;
}
interface BlockListenerContext {
    block: Block;
}
interface NetworkListenerArguments {
    'block': {
        callback: (data: BlockListenerContext) => (Promise<{
            requiresWork?: boolean;
        }> | {
            requiresWork?: boolean;
        });
    };
}
interface BlockListenerScanOptions {
    searchTo?: {
        extended: true;
    } | number | undefined;
}
export declare class BlockListener {
    #private;
    constructor(config: BlockListenerConfig);
    get logger(): Logger | undefined;
    scan(options?: BlockListenerScanOptions): Promise<{
        listenersHaveWork: boolean;
    }>;
    on<K extends keyof NetworkListenerArguments>(_ignore_type: K, args: NetworkListenerArguments[K]): {
        remove: () => void;
    };
}
type BlockQueueRunnerRequest = {
    blockHash: BlockHash;
};
type BlockQueueRunnerRequestSerialized = {
    blockHash: string;
};
interface BaseBlockOperationQueueRunnerScanOptionsRequired {
    scanWhenRunning: true;
    extendedScanIntervalMs: number;
    regularScanIntervalMs: number;
}
type BlockOperationQueueRunnerConfig<Request, Result, RequestSerialized extends JSONSerializable, ResultSerialized extends JSONSerializable | null> = ConstructorParameters<typeof KeetaAnchorQueueRunner<Request, Result, RequestSerialized, ResultSerialized>>[0] & {
    listener: BlockListener | BlockListenerConfig;
    scanOptions?: Partial<BaseBlockOperationQueueRunnerScanOptionsRequired> | {
        scanWhenRunning: false;
    };
};
declare abstract class BaseBlockOperationQueueRunner<Request, Result = null, RequestSerialized extends JSONSerializable = JSONSerializable, ResultSerialized extends JSONSerializable = null> extends KeetaAnchorQueueRunner<Request, Result, RequestSerialized, ResultSerialized> {
    #private;
    constructor(config: BlockOperationQueueRunnerConfig<Request, Result, RequestSerialized, ResultSerialized>);
    protected abstract onBlockSeen(block: Block): Promise<boolean>;
    protected decodeResponse(response: ResultSerialized): Result | null;
    protected encodeResponse(response: Result): ResultSerialized;
    run(options?: KeetaAnchorQueueRunOptions): Promise<boolean>;
    [Symbol.dispose](): void;
}
export declare abstract class BlockQueueRunner<UserResult = null, QueueResult extends JSONSerializable = null> extends BaseBlockOperationQueueRunner<BlockQueueRunnerRequest, UserResult, BlockQueueRunnerRequestSerialized, QueueResult> {
    protected abstract filterBlock(block: Block): (boolean | Promise<boolean>);
    protected decodeRequest(request: BlockQueueRunnerRequestSerialized): BlockQueueRunnerRequest;
    protected encodeRequest(request: BlockQueueRunnerRequest): BlockQueueRunnerRequestSerialized;
    protected onBlockSeen(block: Block): Promise<boolean>;
    add(request: BlockQueueRunnerRequest, info?: KeetaAnchorQueueEntryExtra): Promise<KeetaAnchorQueueRequestID>;
}
type OperationQueueRunnerRequest = {
    blockHash: BlockHash;
    operationIndex: number;
};
type OperationQueueRunnerRequestSerialized = {
    blockHash: string;
    operationIndex: number;
};
export declare abstract class OperationQueueRunner<UserResult = null, QueueResult extends JSONSerializable = null> extends BaseBlockOperationQueueRunner<OperationQueueRunnerRequest, UserResult, OperationQueueRunnerRequestSerialized, QueueResult> {
    protected abstract filterOperation(operation: BlockOperations, context: {
        block: Block;
        operationIndex: number;
    }): (boolean | Promise<boolean>);
    protected decodeRequest(request: OperationQueueRunnerRequestSerialized): OperationQueueRunnerRequest;
    protected encodeRequest(request: OperationQueueRunnerRequest): OperationQueueRunnerRequestSerialized;
    protected onBlockSeen(block: Block): Promise<boolean>;
    add(request: OperationQueueRunnerRequest, info?: KeetaAnchorQueueEntryExtra): Promise<KeetaAnchorQueueRequestID>;
}
export {};
//# sourceMappingURL=block-listener.d.ts.map