Keeta LogoKeeta Logo@keetanetwork/keetanet-client
    Preparing search index...

    Interface LedgerStorageAPI

    Each Ledger Storage backend must implement this interface

    interface LedgerStorageAPI {
        abortTransaction: (transaction: any) => Promise<void>;
        addPendingVote: (
            transaction: any,
            blocksAndVote: VoteStaple,
        ) => Promise<void>;
        adjust: (
            transaction: any,
            input: VoteStaple,
            changes: ComputedEffectOfBlocks,
        ) => Promise<BlockHash[]>;
        beginTransaction: (
            transactionBase: LedgerStorageTransactionBase,
        ) => Promise<LedgerStorageTransactionBase>;
        cache?: (transaction: any) => undefined | LedgerRequestCache;
        commitTransaction: (transaction: any) => Promise<void>;
        delegatedWeight: (
            transaction: any,
            rep?: Account<ECDSA_SECP256K1 | ED25519 | ECDSA_SECP256R1>,
        ) => Promise<bigint>;
        destroy?: () => Promise<void>;
        evaluateError: (error: any) => Promise<any>;
        gc: (transaction: any) => Promise<boolean>;
        getAccountInfo: (
            transaction: any,
            account: string | GenericAccount,
        ) => Promise<AccountInfo>;
        getAccountRep: (
            transaction: any,
            account: string | Account<ECDSA_SECP256K1 | ED25519 | ECDSA_SECP256R1>,
        ) => Promise<null | Account<ECDSA_SECP256K1 | ED25519 | ECDSA_SECP256R1>>;
        getAllBalances: (
            transaction: any,
            account: GenericAccount,
        ) => Promise<GetAllBalancesResponse>;
        getBalance: (
            transaction: any,
            account: GenericAccount,
            token: TokenAddress,
        ) => Promise<bigint>;
        getBlock: (
            transaction: any,
            block: BlockHash,
            from: LedgerSelector,
        ) => Promise<null | Block>;
        getBlockFromPrevious: (
            transaction: any,
            block: BlockHash,
            from: LedgerSelector,
        ) => Promise<null | Block>;
        getBlockHeight: (
            transaction: any,
            blockHash: BlockHash,
            account: GenericAccount,
        ) => Promise<null | { blockHeight: null | string }>;
        getHeadBlock: (
            transaction: any,
            account: GenericAccount,
            from: LedgerSelector,
        ) => Promise<null | Block>;
        getHeadBlocks: (
            transaction: any,
            accounts: GenericAccount[],
            from: LedgerSelector,
        ) => Promise<{ [account: string]: null | Block }>;
        getHistory: (
            transaction: any,
            account: GenericAccount,
            start: null | VoteBlockHash,
            limit?: number,
        ) => Promise<VoteBlockHash[]>;
        getNextSerialNumber: (transaction?: any) => Promise<bigint>;
        getVotes: (
            transaction: any,
            block: BlockHash,
            from: LedgerSelector,
        ) => Promise<null | Vote[]>;
        getVotesAfter: (
            transaction: any,
            moment: Date,
            startKey?: string,
            options?: GetVotesAfterOptions,
        ) => Promise<PaginatedVotes>;
        getVotesFromMultiplePrevious: (
            transaction: any,
            prevBlocks: BlockHash[],
            from: LedgerSelector,
            issuer?: Account<ECDSA_SECP256K1 | ED25519 | ECDSA_SECP256R1>,
        ) => Promise<{ [hash: string]: null | Vote[] }>;
        getVotesFromPrevious: (
            transaction: any,
            block: BlockHash,
            from: LedgerSelector,
        ) => Promise<null | Vote[]>;
        getVoteStaples: (
            transaction: any,
            voteBlockHashes: VoteBlockHash[],
            from: LedgerSelector,
        ) => Promise<VoteBlockHashMap<null | VoteStaple>>;
        getVoteStaplesFromBlockHash?: (
            transaction: any,
            blocks: BlockHash[],
            from: LedgerSelector,
        ) => Promise<VoteStaple[]>;
        init: (config: LedgerConfig, ledger: Ledger) => void;
        listACLsByEntity: (
            transaction: any,
            entity: GenericAccount,
        ) => Promise<ACLRow[]>;
        listACLsByPrincipal: (
            transaction: any,
            principal: GenericAccount,
            entityList?: GenericAccount[],
        ) => Promise<ACLRow[]>;
        listOwners: (
            transaction: any,
            identifier: IdentifierAddress,
            target?: GenericAccount,
        ) => Promise<GenericAccount[]>;
        runPostAdjustHeapDequeue: (
            transaction: any,
            blockPrevHashes?: string[] | BlockHash[],
        ) => Promise<BlockHash[]>;
        stats: () => Promise<LedgerStatistics>;
    }
    Index

    Properties

    abortTransaction: (transaction: any) => Promise<void>

    Abort an active transaction

    addPendingVote: (transaction: any, blocksAndVote: VoteStaple) => Promise<void>

    Add a transitional vote (to the side-ledger)

    adjust: (
        transaction: any,
        input: VoteStaple,
        changes: ComputedEffectOfBlocks,
    ) => Promise<BlockHash[]>

    Adjust the ledger by performing a set of changes based on some blocks and votes

    beginTransaction: (
        transactionBase: LedgerStorageTransactionBase,
    ) => Promise<LedgerStorageTransactionBase>

    Begin a transaction

    cache?: (transaction: any) => undefined | LedgerRequestCache

    Get the cache for a transaction (optional)

    commitTransaction: (transaction: any) => Promise<void>

    Commit an active transaction

    delegatedWeight: (
        transaction: any,
        rep?: Account<ECDSA_SECP256K1 | ED25519 | ECDSA_SECP256R1>,
    ) => Promise<bigint>

    Get the amount of delegated weight for an account, if "rep" is not supplied get the total delegated weight

    destroy?: () => Promise<void>

    Optional destructor

    evaluateError: (error: any) => Promise<any>

    Evaluate error and return expected error (eg. KeetaNetLedgerError)

    gc: (transaction: any) => Promise<boolean>

    Perform Garbage Collection

    getAccountInfo: (
        transaction: any,
        account: string | GenericAccount,
    ) => Promise<AccountInfo>

    Get account information (name, description) If token account, return supply If non user account, returns default permissions

    getAccountRep: (
        transaction: any,
        account: string | Account<ECDSA_SECP256K1 | ED25519 | ECDSA_SECP256R1>,
    ) => Promise<null | Account<ECDSA_SECP256K1 | ED25519 | ECDSA_SECP256R1>>

    Get the Account Representative

    getAllBalances: (
        transaction: any,
        account: GenericAccount,
    ) => Promise<GetAllBalancesResponse>

    Get all balances on a user account for a token

    getBalance: (
        transaction: any,
        account: GenericAccount,
        token: TokenAddress,
    ) => Promise<bigint>

    Get the balance of an account or token

    getBlock: (
        transaction: any,
        block: BlockHash,
        from: LedgerSelector,
    ) => Promise<null | Block>

    Request a block

    getBlockFromPrevious: (
        transaction: any,
        block: BlockHash,
        from: LedgerSelector,
    ) => Promise<null | Block>

    Get a block based on the previous hash of a block

    getBlockHeight: (
        transaction: any,
        blockHash: BlockHash,
        account: GenericAccount,
    ) => Promise<null | { blockHeight: null | string }>

    Get the block height from a given block hash

    getHeadBlock: (
        transaction: any,
        account: GenericAccount,
        from: LedgerSelector,
    ) => Promise<null | Block>

    Get the HEAD block for an account (implemented by LedgerStorageBase using getHeadBlocks())

    getHeadBlocks: (
        transaction: any,
        accounts: GenericAccount[],
        from: LedgerSelector,
    ) => Promise<{ [account: string]: null | Block }>

    Get multiple head blocks at the same time for a set of accounts

    getHistory: (
        transaction: any,
        account: GenericAccount,
        start: null | VoteBlockHash,
        limit?: number,
    ) => Promise<VoteBlockHash[]>

    Get the history for a specific account

    getNextSerialNumber: (transaction?: any) => Promise<bigint>

    Get the next serial number for a representative

    getVotes: (
        transaction: any,
        block: BlockHash,
        from: LedgerSelector,
    ) => Promise<null | Vote[]>

    Get the votes for a given block

    getVotesAfter: (
        transaction: any,
        moment: Date,
        startKey?: string,
        options?: GetVotesAfterOptions,
    ) => Promise<PaginatedVotes>

    Get Votes after a specific moment

    getVotesFromMultiplePrevious: (
        transaction: any,
        prevBlocks: BlockHash[],
        from: LedgerSelector,
        issuer?: Account<ECDSA_SECP256K1 | ED25519 | ECDSA_SECP256R1>,
    ) => Promise<{ [hash: string]: null | Vote[] }>

    Get multiple votes based on the successors of provided block hashes (both sides)

    getVotesFromPrevious: (
        transaction: any,
        block: BlockHash,
        from: LedgerSelector,
    ) => Promise<null | Vote[]>

    Get a vote based on the previous hash of a block

    getVoteStaples: (
        transaction: any,
        voteBlockHashes: VoteBlockHash[],
        from: LedgerSelector,
    ) => Promise<VoteBlockHashMap<null | VoteStaple>>

    Get a vote staple from a Vote Block Hash, which uniquely identifies a set of blocks voted on together

    getVoteStaplesFromBlockHash?: (
        transaction: any,
        blocks: BlockHash[],
        from: LedgerSelector,
    ) => Promise<VoteStaple[]>

    Get Vote Staples from a set of block hashes (optional)

    init: (config: LedgerConfig, ledger: Ledger) => void

    Initialization

    listACLsByEntity: (
        transaction: any,
        entity: GenericAccount,
    ) => Promise<ACLRow[]>

    List permissions any principal has on provided entity

    listACLsByPrincipal: (
        transaction: any,
        principal: GenericAccount,
        entityList?: GenericAccount[],
    ) => Promise<ACLRow[]>

    List permissions principal has on all provided entity's

    listOwners: (
        transaction: any,
        identifier: IdentifierAddress,
        target?: GenericAccount,
    ) => Promise<GenericAccount[]>

    List all owners of an account

    runPostAdjustHeapDequeue: (
        transaction: any,
        blockPrevHashes?: string[] | BlockHash[],
    ) => Promise<BlockHash[]>

    Process heap blocks that have become ready to process

    stats: () => Promise<LedgerStatistics>

    Get ledger statistics