import { models } from "@phantomcores/crypto"; import { EventEmitter, Logger } from "../index"; import { IDelegatesBusinessRepository, IWalletsBusinessRepository } from "./business-repository"; import { IDatabaseConnection } from "./database-connection"; import { IWalletManager } from "./wallet-manager"; export interface IDatabaseService { walletManager: IWalletManager; wallets: IWalletsBusinessRepository; delegates: IDelegatesBusinessRepository; connection: IDatabaseConnection; logger: Logger.ILogger; emitter: EventEmitter.EventEmitter; config: any; options: any; cache: Map; restoredDatabaseIntegrity: boolean; verifyBlockchain(): Promise<{ valid: boolean; errors: any[]; }>; getActiveDelegates(height: number, delegates?: any[]): Promise; buildWallets(height: number): Promise; saveWallets(force: boolean): Promise; saveBlock(block: models.Block): Promise; enqueueSaveBlock(block: models.Block): void; enqueueDeleteBlock(block: models.Block): void; enqueueDeleteRound(height: number): void; commitQueuedQueries(): Promise; deleteBlock(block: models.Block): Promise; getBlock(id: string): Promise; getLastBlock(): Promise; getBlocks(offset: number, limit: number): Promise; /** * Get the blocks at the given heights. * The transactions for those blocks will not be loaded like in `getBlocks()`. * @param {Array} heights array of arbitrary block heights * @return {Array} array for the corresponding blocks. The element (block) at index `i` * in the resulting array corresponds to the requested height at index `i` in the input * array heights[]. For example, if * heights[0] = 100 * heights[1] = 200 * heights[2] = 150 * then the result array will have the same number of elements (3) and will be: * result[0] = block at height 100 * result[1] = block at height 200 * result[2] = block at height 150 * If some of the requested blocks do not exist in our chain (requested height is larger than * the height of our blockchain), then that element will be `undefined` in the resulting array * @throws Error */ getBlocksByHeight(heights: number[]): Promise; getTopBlocks(count: any): Promise; getRecentBlockIds(): Promise; saveRound(activeDelegates: object[]): Promise; deleteRound(round: any): Promise; getTransaction(id: string): Promise; getForgedTransactionsIds(ids: string[]): Promise; init(): Promise; loadBlocksFromCurrentRound(): Promise; loadTransactionsForBlocks(blocks: any): Promise; updateDelegateStats(delegates: any[]): void; applyRound(height: number): Promise; revertRound(height: number): Promise; applyBlock(block: models.Block): Promise; revertBlock(block: models.Block): Promise; verifyTransaction(transaction: models.Transaction): Promise; getBlocksForRound(round?: number): Promise; getCommonBlocks(ids: string[]): Promise; }