import { VoteStaple, Vote } from '../vote'; import { Block, BlockHash } from '../block'; import type { VoteBlockHash, VoteBlockHashMap } from '../vote'; import type { GenericAccount, IdentifierAddress, TokenAddress } from '../account'; import Account, { AccountKeyAlgorithm } from '../account'; import type { Ledger, LedgerConfig, LedgerStorageAPI, LedgerSelector, PaginatedVotes, GetVotesAfterOptions, LedgerStorageTransactionBaseOptions, ListACLsByEntityFilters } from '../ledger'; import { IdempotentKey, LedgerStorageTransactionBase } from '../ledger'; import type { ACLRow, GetAllBalancesResponse, LedgerStatistics, CertificateWithIntermediates, AccountInfoForType } from './types'; import { LedgerStorageBase } from './common'; import type { PoolClient as PostgresPoolClient } from 'pg'; import { Pool as PostgresPool } from 'pg'; import type { ComputedEffectOfBlocks } from './effects'; import LedgerRequestCache from './cache'; import type { CertificateHash } from '../utils/certificate'; declare class PostgresTransaction extends LedgerStorageTransactionBase { client: PostgresPoolClient; cache: LedgerRequestCache; constructor(transactionBase: LedgerStorageTransactionBaseOptions, db: PostgresPoolClient); } interface PostgresSelectOptions { forUpdate?: boolean; } export type PostgresConfig = NonNullable[0]>; export declare class DBPostgres extends LedgerStorageBase implements LedgerStorageAPI { #private; constructor(); init(config: LedgerConfig, ledger: Ledger): void; destroy(): Promise; beginTransaction(transactionBase: LedgerStorageTransactionBaseOptions): Promise; commitTransaction(transaction: PostgresTransaction): Promise; abortTransaction(transaction: PostgresTransaction): Promise; cache(transaction: PostgresTransaction): LedgerRequestCache; evaluateError(error: any): Promise; delegatedWeight(transaction: PostgresTransaction, rep?: Account | InstanceType, options?: PostgresSelectOptions): Promise; getBalance(transaction: PostgresTransaction, account: GenericAccount, token: TokenAddress, options?: PostgresSelectOptions): Promise; getAllBalances(transaction: PostgresTransaction, account: GenericAccount): Promise; addPendingVote(transaction: PostgresTransaction, votesAndBlocks: VoteStaple): Promise; getAccountRep(transaction: PostgresTransaction, userAccount: GenericAccount | string): Promise; /** * If an adjustment cannot be made right now, defer it for follow-up */ protected adjustDefer(transaction: PostgresTransaction, input: VoteStaple): Promise; listOwners(transaction: PostgresTransaction, entity: IdentifierAddress): Promise[]>; listACLsByEntity(transaction: PostgresTransaction, entity: GenericAccount, options?: ListACLsByEntityFilters): Promise; listACLsByPrincipal(transaction: PostgresTransaction, principal: ACLRow['principal'], entityList?: GenericAccount[]): Promise; getAccountInfo(transaction: PostgresTransaction, account: Account | string): Promise>; adjust(transaction: PostgresTransaction, input: VoteStaple, changes: ComputedEffectOfBlocks, mayDefer?: boolean, completedStaples?: Set): Promise; getBlock(transaction: PostgresTransaction, block: BlockHash, from: LedgerSelector): Promise; getBlockHeight(transaction: PostgresTransaction, blockHash: BlockHash, account: GenericAccount): Promise; getBlockHeights(transaction: PostgresTransaction, toFetch: { blockHash: BlockHash; account: GenericAccount; }[]): Promise<{ [blockHash: string]: bigint | null; }>; getVotes(transaction: PostgresTransaction, block: BlockHash, from: LedgerSelector, issuer?: GenericAccount): Promise; getVoteStaples(transaction: PostgresTransaction, stapleBlockHashes: VoteBlockHash[], from?: LedgerSelector): Promise>; getHistory(transaction: PostgresTransaction, account: GenericAccount | null, start: VoteBlockHash | null, limit?: number): Promise; getBlockFromPrevious(transaction: PostgresTransaction, prevBlock: BlockHash, from: LedgerSelector): Promise; getVotesFromMultiplePrevious(transaction: PostgresTransaction, prevBlocks: BlockHash[], from: LedgerSelector, issuer?: Account): Promise<{ [hash: string]: Vote[] | null; }>; getHeadBlocks(transaction: PostgresTransaction, accounts: GenericAccount[], from: LedgerSelector): Promise<{ [publicKey: string]: Block | null; }>; getVoteStaplesFromBlockHash(transaction: PostgresTransaction, blocks: BlockHash[], onLedger: LedgerSelector): Promise; getVotesAfter(transaction: PostgresTransaction, moment: Date, startKey?: string, options?: GetVotesAfterOptions): Promise; getAccountCertificates(transaction: PostgresTransaction, account: GenericAccount): Promise; getAccountCertificateByHash(transaction: PostgresTransaction, account: GenericAccount, hash: CertificateHash): Promise; protected gcBatch(transaction: PostgresTransaction): Promise; getNextSerialNumber(): Promise; getIdempotentBlockHash(transaction: PostgresTransaction, idempotent: IdempotentKey, from: LedgerSelector, excludeBlockHash?: BlockHash): Promise; stats(): Promise; } export declare const Testing: { createDatabase: (config: PostgresConfig) => Promise; deleteDatabase: (config: PostgresConfig) => Promise; }; export default DBPostgres;