import { StateManager as StateManagerTypes } from '@shardeum-foundation/lib-types';
import * as Shardus from '../shardus/shardus-types';
import { Logger as L4jsLogger } from 'log4js';
import StateManager from '.';
import Crypto from '../crypto';
import Logger from '../logger';
import { P2PModuleContext as P2P } from '../p2p/Context';
import Storage from '../storage';
import Profiler from '../utils/profiler';
import { SyncTrackerInterface } from './NodeSyncTracker';
import { CycleShardData, GlobalAccountReportResp } from './state-manager-types';
type SyncStatment = {
    p2pJoinTime: number;
    timeBeforeDataSync: number;
    timeBeforeDataSync2: number;
    totalSyncTime: number;
    cycleStarted: number;
    cycleEnded: number;
    numCycles: number;
    syncComplete: boolean;
    numNodesOnStart: number;
    syncStartTime: number;
    syncEndTime: number;
    syncSeconds: number;
    syncRanges: number;
    failedAccountLoops: number;
    failedAccounts: number;
    failAndRestart: number;
    discardedTXs: number;
    nonDiscardedTXs: number;
    numSyncedState: number;
    numAccounts: number;
    numGlobalAccounts: number;
    internalFlag: boolean;
};
declare class AccountSync {
    stateManager: StateManager;
    app: Shardus.App;
    crypto: Crypto;
    config: Shardus.StrictServerConfiguration;
    profiler: Profiler;
    logger: Logger;
    p2p: P2P;
    storage: Storage;
    mainLogger: L4jsLogger;
    fatalLogger: L4jsLogger;
    shardLogger: L4jsLogger;
    statsLogger: L4jsLogger;
    dataSyncMainPhaseComplete: boolean;
    globalAccountsSynced: boolean;
    isSyncingAcceptedTxs: boolean;
    requiredNodeCount: number;
    runtimeSyncTrackerSyncing: boolean;
    syncTrackerIndex: number;
    initalSyncRemaining: number;
    readyforTXs: boolean;
    syncTrackers: SyncTrackerInterface[];
    lastWinningGlobalReportNodes: Shardus.Node[];
    statemanager_fatal: (key: string, log: string) => void;
    syncStatement: SyncStatment;
    isSyncStatementCompleted: boolean;
    softSync_earlyOut: boolean;
    softSync_noSyncDelay: boolean;
    softSync_checkInitialFlag: boolean;
    initalSyncFinished: boolean;
    forceSyncComplete: boolean;
    /** at the start of a sync operation go ahead and ask for the next data source */
    dataSourceTest: boolean;
    /** thow assert in the top level loop that managed sync trackers. Causes reset-sync-ranges.*/
    debugFail1: boolean;
    /** thow assert in the top level loop that managed sync trackers. Causes APOP. Auto reverts debugFail2 to false*/
    debugFail2: boolean;
    /** throw assert in the sync tracker loop that gets accounts. */
    debugFail3: boolean;
    /** if dataSourceTest is true, then keep asking for a new node every one second until things break. */
    debugFail4: boolean;
    constructor(stateManager: StateManager, profiler: Profiler, app: Shardus.App, logger: Logger, storage: Storage, p2p: P2P, crypto: Crypto, config: Shardus.StrictServerConfiguration);
    clearSyncData(): void;
    clearSyncTrackers(): void;
    /***
     *    ##     ##    ###    ##    ## ########  ##       ######## ########   ######
     *    ##     ##   ## ##   ###   ## ##     ## ##       ##       ##     ## ##    ##
     *    ##     ##  ##   ##  ####  ## ##     ## ##       ##       ##     ## ##
     *    ######### ##     ## ## ## ## ##     ## ##       ######   ########   ######
     *    ##     ## ######### ##  #### ##     ## ##       ##       ##   ##         ##
     *    ##     ## ##     ## ##   ### ##     ## ##       ##       ##    ##  ##    ##
     *    ##     ## ##     ## ##    ## ########  ######## ######## ##     ##  ######
     */
    setupHandlers(): void;
    /***
     *    #### ##    ## #### ######## ####    ###    ##        ######  ##    ## ##    ##  ######  ##     ##    ###    #### ##    ##
     *     ##  ###   ##  ##     ##     ##    ## ##   ##       ##    ##  ##  ##  ###   ## ##    ## ###   ###   ## ##    ##  ###   ##
     *     ##  ####  ##  ##     ##     ##   ##   ##  ##       ##         ####   ####  ## ##       #### ####  ##   ##   ##  ####  ##
     *     ##  ## ## ##  ##     ##     ##  ##     ## ##        ######     ##    ## ## ## ##       ## ### ## ##     ##  ##  ## ## ##
     *     ##  ##  ####  ##     ##     ##  ######### ##             ##    ##    ##  #### ##       ##     ## #########  ##  ##  ####
     *     ##  ##   ###  ##     ##     ##  ##     ## ##       ##    ##    ##    ##   ### ##    ## ##     ## ##     ##  ##  ##   ###
     *    #### ##    ## ####    ##    #### ##     ## ########  ######     ##    ##    ##  ######  ##     ## ##     ## #### ##    ##
     */
    /**
     * initialSyncMain
     * syncs state table data and account data
     * this is only called when a node is first syncing into the network
     *   later on syncing will be from runtime syncTracker ranges
     * @param requiredNodeCount
     */
    initialSyncMain(requiredNodeCount: number): Promise<void>;
    private waitForValidShardData;
    private initRangesToSync;
    /***
     *     ######   ######## ######## ########   #######  ########  ##     ##  ######  ########  ######   ##        #######  ########     ###    ##       ########  ######## ########   #######  ########  ########
     *    ##    ##  ##          ##    ##     ## ##     ## ##     ## ##     ## ##    ##    ##    ##    ##  ##       ##     ## ##     ##   ## ##   ##       ##     ## ##       ##     ## ##     ## ##     ##    ##
     *    ##        ##          ##    ##     ## ##     ## ##     ## ##     ## ##          ##    ##        ##       ##     ## ##     ##  ##   ##  ##       ##     ## ##       ##     ## ##     ## ##     ##    ##
     *    ##   #### ######      ##    ########  ##     ## ########  ##     ##  ######     ##    ##   #### ##       ##     ## ########  ##     ## ##       ########  ######   ########  ##     ## ########     ##
     *    ##    ##  ##          ##    ##   ##   ##     ## ##     ## ##     ##       ##    ##    ##    ##  ##       ##     ## ##     ## ######### ##       ##   ##   ##       ##        ##     ## ##   ##      ##
     *    ##    ##  ##          ##    ##    ##  ##     ## ##     ## ##     ## ##    ##    ##    ##    ##  ##       ##     ## ##     ## ##     ## ##       ##    ##  ##       ##        ##     ## ##    ##     ##
     *     ######   ########    ##    ##     ##  #######  ########   #######   ######     ##     ######   ########  #######  ########  ##     ## ######## ##     ## ######## ##         #######  ##     ##    ##
     */
    /**
     * getRobustGlobalReport
     * This function can throw exceptions that are used in flow control.  Calling code must expext this
     *
     * @param tag a debug tag so that logs and counters will give more context
     * @returns GlobalAccountReportResp
     */
    getRobustGlobalReport(tag?: string, syncFromArchiver?: boolean): Promise<GlobalAccountReportResp>;
    /**
     * failandRestart
     *     this is going away
     */
    failandRestart_depricated(): Promise<void>;
    /**
     * failAndDontRestartSync
     */
    failAndDontRestartSync(): void;
    /***
     *    ########  ##     ## ##    ## ######## #### ##     ## ########     ######  ##    ## ##    ##  ######  ##     ##    ###    ##    ## ########  ##       ######## ########   ######
     *    ##     ## ##     ## ###   ##    ##     ##  ###   ### ##          ##    ##  ##  ##  ###   ## ##    ## ##     ##   ## ##   ###   ## ##     ## ##       ##       ##     ## ##    ##
     *    ##     ## ##     ## ####  ##    ##     ##  #### #### ##          ##         ####   ####  ## ##       ##     ##  ##   ##  ####  ## ##     ## ##       ##       ##     ## ##
     *    ########  ##     ## ## ## ##    ##     ##  ## ### ## ######       ######     ##    ## ## ## ##       ######### ##     ## ## ## ## ##     ## ##       ######   ########   ######
     *    ##   ##   ##     ## ##  ####    ##     ##  ##     ## ##                ##    ##    ##  #### ##       ##     ## ######### ##  #### ##     ## ##       ##       ##   ##         ##
     *    ##    ##  ##     ## ##   ###    ##     ##  ##     ## ##          ##    ##    ##    ##   ### ##    ## ##     ## ##     ## ##   ### ##     ## ##       ##       ##    ##  ##    ##
     *    ##     ##  #######  ##    ##    ##    #### ##     ## ########     ######     ##    ##    ##  ######  ##     ## ##     ## ##    ## ########  ######## ######## ##     ##  ######
     */
    /**
     * updateRuntimeSyncTrackers
     *
     * called in update shard values to handle sync trackers that have finished and need to restar TXs
     */
    updateRuntimeSyncTrackers(): void;
    /***
     *     ######  ##    ## ##    ##  ######  ########  ##     ## ##    ## ######## #### ##     ## ######## ######## ########     ###     ######  ##    ## ######## ########   ######
     *    ##    ##  ##  ##  ###   ## ##    ## ##     ## ##     ## ###   ##    ##     ##  ###   ### ##          ##    ##     ##   ## ##   ##    ## ##   ##  ##       ##     ## ##    ##
     *    ##         ####   ####  ## ##       ##     ## ##     ## ####  ##    ##     ##  #### #### ##          ##    ##     ##  ##   ##  ##       ##  ##   ##       ##     ## ##
     *     ######     ##    ## ## ## ##       ########  ##     ## ## ## ##    ##     ##  ## ### ## ######      ##    ########  ##     ## ##       #####    ######   ########   ######
     *          ##    ##    ##  #### ##       ##   ##   ##     ## ##  ####    ##     ##  ##     ## ##          ##    ##   ##   ######### ##       ##  ##   ##       ##   ##         ##
     *    ##    ##    ##    ##   ### ##    ## ##    ##  ##     ## ##   ###    ##     ##  ##     ## ##          ##    ##    ##  ##     ## ##    ## ##   ##  ##       ##    ##  ##    ##
     *     ######     ##    ##    ##  ######  ##     ##  #######  ##    ##    ##    #### ##     ## ########    ##    ##     ## ##     ##  ######  ##    ## ######## ##     ##  ######
     */
    /**
     * syncRuntimeTrackers
     */
    syncRuntimeTrackers(): Promise<void>;
    /***
     *     ######  ##    ## ##    ##  ######  ######## ########     ###     ######  ##    ## ######## ########     ##     ## ######## ##       ########  ######## ########   ######
     *    ##    ##  ##  ##  ###   ## ##    ##    ##    ##     ##   ## ##   ##    ## ##   ##  ##       ##     ##    ##     ## ##       ##       ##     ## ##       ##     ## ##    ##
     *    ##         ####   ####  ## ##          ##    ##     ##  ##   ##  ##       ##  ##   ##       ##     ##    ##     ## ##       ##       ##     ## ##       ##     ## ##
     *     ######     ##    ## ## ## ##          ##    ########  ##     ## ##       #####    ######   ########     ######### ######   ##       ########  ######   ########   ######
     *          ##    ##    ##  #### ##          ##    ##   ##   ######### ##       ##  ##   ##       ##   ##      ##     ## ##       ##       ##        ##       ##   ##         ##
     *    ##    ##    ##    ##   ### ##    ##    ##    ##    ##  ##     ## ##    ## ##   ##  ##       ##    ##     ##     ## ##       ##       ##        ##       ##    ##  ##    ##
     *     ######     ##    ##    ##  ######     ##    ##     ## ##     ##  ######  ##    ## ######## ##     ##    ##     ## ######## ######## ##        ######## ##     ##  ######
     */
    /**
     * createSyncTrackerByRange
     * @param {StateManagerTypes.shardFunctionTypes.BasicAddressRange} range
     * @param {number} cycle
     * @return {SyncTracker}
     */
    createSyncTrackerByRange(range: StateManagerTypes.shardFunctionTypes.BasicAddressRange, cycle: number, initalSync?: boolean, syncFromArchiver?: boolean): SyncTrackerInterface;
    createSyncTrackerByForGlobals(cycle: number, initalSync?: boolean, syncFromArchiver?: boolean): SyncTrackerInterface;
    /**
     * not used, consider removal
     * @param address
     * @returns
     */
    getSyncTracker(address: string): SyncTrackerInterface | null;
    getSyncTrackerForParition(partitionID: number, cycleShardData: CycleShardData): SyncTrackerInterface | null;
    /***
     *    ##     ## ####  ######   ######
     *    ###   ###  ##  ##    ## ##    ##
     *    #### ####  ##  ##       ##
     *    ## ### ##  ##   ######  ##
     *    ##     ##  ##        ## ##
     *    ##     ##  ##  ##    ## ##    ##
     *    ##     ## ####  ######   ######
     */
    /**
     * syncStatmentIsComplete
     *
     */
    syncStatmentIsComplete(): void;
    /**
     * Skips app data sync and sets flags to enable external tx processing.
     * Called by snapshot module after data recovery is complete.
     */
    skipSync(): void;
    setGlobalSyncFinished(): void;
    reSyncGlobals(): void;
}
export default AccountSync;
