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<VoteStaple[]>;
        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>
                | InstanceSet<
                    Account<AccountKeyAlgorithm>,

                        | `0x00${string}`
                        | `0x01${string}`
                        | `0x03${string}`
                        | `0x02${string}`
                        | `0x04${string}`
                        | `0x06${string}`
                        | `0x07${string}`,
                >,
        ) => Promise<bigint>;
        destroy?: () => Promise<void>;
        evaluateError: (error: any) => Promise<any>;
        gc: (transaction: any) => Promise<boolean>;
        getAccountCertificateByHash: (
            transaction: any,
            account: GenericAccount,
            hash: CertificateHash,
        ) => Promise<null | CertificateWithIntermediates>;
        getAccountCertificates: (
            transaction: any,
            account: GenericAccount,
        ) => Promise<CertificateWithIntermediates[]>;
        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 | bigint>;
        getBlockHeights: (
            transaction: any,
            toFetch: { account: GenericAccount; blockHash: BlockHash }[],
        ) => Promise<{ [blockHash: string]: null | bigint }>;
        getHeadBlock: (
            transaction: any,
            account: GenericAccount,
            from: LedgerSelector,
        ) => Promise<null | Block>;
        getHeadBlockHashes: (
            transaction: any,
            accounts: InstanceSet<Account<AccountKeyAlgorithm>>,
        ) => Promise<{ [account: string]: null | BlockHash }>;
        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[]>;
        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<VoteStaple[]>

    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>
            | InstanceSet<
                Account<AccountKeyAlgorithm>,

                    | `0x00${string}`
                    | `0x01${string}`
                    | `0x03${string}`
                    | `0x02${string}`
                    | `0x04${string}`
                    | `0x06${string}`
                    | `0x07${string}`,
            >,
    ) => Promise<bigint>

    Get the amount of delegated weight for an account, if "rep" is not supplied get the total delegated weight, if "rep" is of type Account.Set, return the sum of the weights for the provided account(s)

    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

    getAccountCertificateByHash: (
        transaction: any,
        account: GenericAccount,
        hash: CertificateHash,
    ) => Promise<null | CertificateWithIntermediates>

    Get the X.509 Certificate associated with an account using the certificate hash

    getAccountCertificates: (
        transaction: any,
        account: GenericAccount,
    ) => Promise<CertificateWithIntermediates[]>

    Get the X.509 Certificates associated with an account

    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 | bigint>

    Get the block height from a given block hash

    getBlockHeights: (
        transaction: any,
        toFetch: { account: GenericAccount; blockHash: BlockHash }[],
    ) => Promise<{ [blockHash: string]: null | bigint }>

    Get multiple block heights for a given set of block hashes and chains.

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

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

    getHeadBlockHashes: (
        transaction: any,
        accounts: InstanceSet<Account<AccountKeyAlgorithm>>,
    ) => Promise<{ [account: string]: null | BlockHash }>

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

    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

    stats: () => Promise<LedgerStatistics>

    Get ledger statistics