import { SQLiteDriver } from "./drivers/SQLiteDriver"; import { ConfDTO } from "../dto/ConfDTO"; import { BlockDTO } from "../dto/BlockDTO"; import { DBHead } from "../db/DBHead"; import { DBIdentity, IdentityDAL } from "./sqliteDAL/IdentityDAL"; import { CindexEntry, FullIindexEntry, IindexEntry, IndexEntry, MindexEntry, SimpleTxInput, SimpleUdEntryForWallet, SindexEntry } from "../indexer"; import { TransactionDTO } from "../dto/TransactionDTO"; import { CertDAL, DBCert } from "./sqliteDAL/CertDAL"; import { DBBlock } from "../db/DBBlock"; import { DBMembership, MembershipDAL } from "./sqliteDAL/MembershipDAL"; import { MerkleDTO } from "../dto/MerkleDTO"; import { PowDAL } from "./fileDALs/PowDAL"; import { Initiable } from "./sqliteDAL/Initiable"; import { MetaDAL } from "./sqliteDAL/MetaDAL"; import { BasicRevocableIdentity } from "../dto/IdentityDTO"; import { FileSystem } from "../system/directory"; import { Wot } from "../../../neon/lib"; import { IIndexDAO } from "./indexDAL/abstract/IIndexDAO"; import { BIndexDAO } from "./indexDAL/abstract/BIndexDAO"; import { MIndexDAO } from "./indexDAL/abstract/MIndexDAO"; import { SIndexDAO } from "./indexDAL/abstract/SIndexDAO"; import { CIndexDAO } from "./indexDAL/abstract/CIndexDAO"; import { IdentityForRequirements } from "../../service/BlockchainService"; import { BlockchainDAO } from "./indexDAL/abstract/BlockchainDAO"; import { TxsDAO } from "./indexDAL/abstract/TxsDAO"; import { WalletDAO } from "./indexDAL/abstract/WalletDAO"; import { PeerDAO } from "./indexDAL/abstract/PeerDAO"; import { DBTx } from "../db/DBTx"; import { DBWallet } from "../db/DBWallet"; import { Tristamp } from "../common/Tristamp"; import { CFSCore } from "./fileDALs/CFSCore"; import { DBPeer } from "../db/DBPeer"; import { DividendDAO } from "./indexDAL/abstract/DividendDAO"; import { HttpSource, HttpUD } from "../../modules/bma/lib/dtos"; import { LevelUp } from "levelup"; import { ConfDAO } from "./indexDAL/abstract/ConfDAO"; import { ServerDAO } from "./server-dao"; export interface FileDALParams { home: string; fs: FileSystem; dbf: () => SQLiteDriver; wotbf: () => Wot; } export interface IndexBatch { mindex: MindexEntry[]; iindex: IindexEntry[]; sindex: SindexEntry[]; cindex: CindexEntry[]; } export declare class FileDAL implements ServerDAO { private params; getSqliteDB: (dbName: string) => Promise; getLevelDB: (dbName: string) => Promise; rootPath: string; fs: FileSystem; sqliteDriver: SQLiteDriver; wotb: Wot; profile: string; powDAL: PowDAL; coreFS: CFSCore; confDAL: ConfDAO; metaDAL: MetaDAL; idtyDAL: IdentityDAL; certDAL: CertDAL; msDAL: MembershipDAL; blockDAL: BlockchainDAO; txsDAL: TxsDAO; peerDAL: PeerDAO; walletDAL: WalletDAO; bindexDAL: BIndexDAO; mindexDAL: MIndexDAO; iindexDAL: IIndexDAO; sindexDAL: SIndexDAO; cindexDAL: CIndexDAO; dividendDAL: DividendDAO; newDals: { [k: string]: Initiable; }; private dals; loadConfHook: (conf: ConfDTO) => Promise; saveConfHook: (conf: ConfDTO) => Promise; constructor(params: FileDALParams, getSqliteDB: (dbName: string) => Promise, getLevelDB: (dbName: string) => Promise); init(conf: ConfDTO): Promise; getDBVersion(): Promise; writeFileOfBlock(block: DBBlock): Promise; writeSideFileOfBlock(block: DBBlock): Promise; listAllPeers(): Promise; getPeer(pubkey: string): Promise; getWS2Peers(): Promise; getAbsoluteBlockInForkWindowByBlockstamp(blockstamp: string): Promise; getAbsoluteValidBlockInForkWindowByBlockstamp(blockstamp: string): Promise; getBlockWeHaveItForSure(number: number): Promise; getBlock(number: number): Promise; getFullBlockOf(number: number): Promise; getBlockstampOf(number: number): Promise; getTristampOf(number: number): Promise; existsAbsoluteBlockInForkWindow(number: number, hash: string): Promise; getAbsoluteBlockInForkWindow(number: number, hash: string): Promise; getAbsoluteValidBlockInForkWindow(number: number, hash: string): Promise; getAbsoluteBlockByNumberAndHash(number: number, hash: string, forceNumberAndHashFinding?: boolean): Promise; getAbsoluteBlockByBlockstamp(blockstamp: string): Promise; existsNonChainableLink(from: string, vHEAD_1: DBHead, sigStock: number): Promise; getCurrentBlockOrNull(): Promise; getPromoted(number: number): Promise; getPotentialRootBlocks(): Promise; lastBlockOfIssuer(issuer: string): Promise; getCountOfPoW(issuer: string): Promise; /** * Find all the blocks in the blockchain whose number is between [start ; end] * @param start Lower number bound (included). * @param end Higher number bound (included). */ getBlocksBetween(start: number, end: number): Promise; getForkBlocksFollowing(current: DBBlock): Promise; getPotentialForkBlocks(numberStart: number, medianTimeStart: number, maxNumber: number): Promise; getBlockCurrent(): Promise; getValidLinksTo(to: string): Promise; getAvailableSourcesByPubkey(pubkey: string): Promise; findByIdentifierPosAmountBase(identifier: string, pos: number, amount: number, base: number, isDividend: boolean): Promise; getGlobalIdentityByHashForExistence(hash: string): Promise; getGlobalIdentityByHashForHashingAndSig(hash: string): Promise<{ pubkey: string; uid: string; buid: string; sig: string; } | null>; getGlobalIdentityByHashForLookup(hash: string): Promise<{ pubkey: string; uid: string; buid: string; sig: string; member: boolean; wasMember: boolean; } | null>; getGlobalIdentityByHashForJoining(hash: string): Promise<{ pubkey: string; uid: string; buid: string; sig: string; member: boolean; wasMember: boolean; revoked: boolean; } | null>; getGlobalIdentityByHashForIsMember(hash: string): Promise<{ pub: string; member: boolean; } | null>; getGlobalIdentityByHashForRevocation(hash: string): Promise<{ pub: string; uid: string; created_on: string; sig: string; member: boolean; wasMember: boolean; revoked: boolean; revocation_sig: string | null; expires_on: number; } | null>; getMembers(): Promise<{ pubkey: string; uid: string | null; }[]>; getWrittenIdtyByPubkeyForHash(pubkey: string): Promise<{ hash: string; }>; getWrittenIdtyByPubkeyForHashing(pubkey: string): Promise<{ uid: string; created_on: string; pub: string; }>; getWrittenIdtyByPubkeyForWotbID(pubkey: string): Promise<{ wotb_id: number; }>; getWrittenIdtyByPubkeyForUidAndPubkey(pubkey: string): Promise<{ pub: string; uid: string; }>; getWrittenIdtyByPubkeyForIsMember(pubkey: string): Promise<{ member: boolean; } | null>; getWrittenIdtyByPubkeyForUidAndIsMemberAndWasMember(pubkey: string): Promise<{ uid: string; member: boolean; wasMember: boolean; } | null>; getWrittenIdtyByPubkeyOrUidForIsMemberAndPubkey(search: string): Promise<{ pub: string; member: boolean; } | null>; getWrittenIdtyByPubkeyOrUIdForHashingAndIsMember(search: string): Promise<{ uid: string; created_on: string; pub: string; member: boolean; } | null>; getWrittenIdtyByPubkeyForRevocationCheck(pubkey: string): Promise<{ pub: string; uid: string; created_on: string; sig: string; revoked_on: string | null; } | null>; getWrittenIdtyByPubkeyForCertificationCheck(pubkey: string): Promise<{ pub: string; uid: string; created_on: string; sig: string; } | null>; getWrittenIdtyByPubkeyForUidAndMemberAndCreatedOn(pubkey: string): Promise<{ uid: string; member: boolean; created_on: string; } | null>; private getWrittenForSureIdtyByPubkey; private getWrittenForSureIdtyByUid; getWrittenIdtyByPubkey(pub: string): Promise; getWrittenIdtyByPubkeyForExistence(uid: string): Promise; getWrittenIdtyByUIDForExistence(uid: string): Promise; getWrittenIdtyByUidForHashing(uid: string): Promise<{ uid: string; created_on: string; pub: string; }>; getWrittenIdtyByUIDForWotbId(uid: string): Promise<{ wotb_id: number; }>; findPeersWhoseHashIsIn(hashes: string[]): Promise; getTxByHash(hash: string): Promise; removeTxByHash(hash: string): Promise; getTransactionsPending(versionMin?: number): Promise; getNonWritten(pubkey: string): Promise; getRevocatingMembers(): Promise; getToBeKickedPubkeys(): Promise; getRevokedPubkeys(): Promise; searchJustIdentities(search: string): Promise; certsToTarget(pub: string, hash: string): Promise; certsFrom(pubkey: string): Promise; cindexEntry2DBCert(entry: CindexEntry): Promise; isSentry(pubkey: string, conf: ConfDTO): Promise; certsFindNew(): Promise; certsNotLinkedToTarget(hash: string): Promise; getMostRecentMembershipNumberForIssuer(issuer: string): Promise; lastJoinOfIdentity(target: string): Promise; findNewcomers(blockMedianTime?: number): Promise; findLeavers(blockMedianTime?: number): Promise; existsNonReplayableLink(from: string, to: string, medianTime: number, version: number): Promise; getSource(identifier: string, pos: number, isDividend: boolean): Promise; isMember(pubkey: string): Promise; isMemberAndNonLeaver(pubkey: string): Promise; isLeaving(pubkey: string): Promise; existsCert(cert: DBCert, current: DBBlock | null): Promise; deleteCert(cert: any): Promise; deleteMS(ms: any): Promise; setRevoked(pubkey: string): Promise; setRevocating: (idty: BasicRevocableIdentity, revocation_sig: string) => Promise; getPeerOrNull(pubkey: string): Promise; removePeerByPubkey(pubkey: string): Promise; findAllPeersBut(pubkeys: string[]): Promise; listAllPeersWithStatusNewUP(): Promise; listAllPeersWithStatusNewUPWithtout(pub: string): Promise; findPeers(pubkey: string): Promise; getRandomlyUPsWithout(pubkeys: string[]): Promise; setPeerUP(pubkey: string): Promise; setPeerDown(pubkey: string): Promise; saveBlock(dbb: DBBlock): Promise; generateIndexes(block: BlockDTO, conf: ConfDTO, index: IndexEntry[], aHEAD: DBHead | null): Promise<{ HEAD: DBHead; mindex: any; iindex: any; sindex: any; cindex: any; dividends: any; }>; updateWotbLinks(cindex: CindexEntry[], instance?: Wot): Promise; trimIndexes(maxNumber: number): Promise; trimSandboxes(block: { medianTime: number; }): Promise; savePendingMembership(ms: DBMembership): Promise; saveBlockInFile(block: DBBlock): Promise; saveSideBlockInFile(block: DBBlock): Promise; saveTxsInFiles(txs: TransactionDTO[], block_number: number, medianTime: number): Promise; merkleForPeers(): Promise; savePendingIdentity(idty: DBIdentity): Promise; revokeIdentity(pubkey: string): Promise; removeUnWrittenWithPubkey(pubkey: string): Promise; removeUnWrittenWithUID(pubkey: string): Promise; registerNewCertification(cert: DBCert): Promise; saveTransaction(tx: DBTx): Promise; getTransactionsHistory(pubkey: string): Promise<{ sent: DBTx[]; received: DBTx[]; sending: DBTx[]; receiving: DBTx[]; pending: DBTx[]; }>; getUDHistory(pubkey: string): Promise<{ history: HttpUD[]; }>; savePeer(peer: DBPeer): Promise; getUniqueIssuersBetween(start: number, end: number): Promise; /** * Gets a range of entries for the last `start`th to the last `end`th HEAD entry. * @param start The starting entry number (min. 1) * @param end The ending entry (max. BINDEX length) * @param property If provided, transforms the range of entries into an array of the asked property. */ range(start: number, end: number, property: string): Promise; /** * Get the last `n`th entry from the BINDEX. * @param n The entry number (min. 1). */ head(n: number): Promise; /*********************** * CONFIGURATION **********************/ getParameters(): Promise; loadConf(overrideConf: ConfDTO, defaultConf?: boolean): Promise; saveConf(confToSave: ConfDTO): Promise; /*********************** * WALLETS **********************/ getWallet(conditions: string): Promise; saveWallet(wallet: DBWallet): Promise; /*********************** * STATISTICS **********************/ getStat(name: StatName): Promise; cleanCaches(): Promise; close(): Promise; resetPeers(): Promise; getLogContent(linesQuantity: number): Promise; findReceiversAbove(minsig: number): Promise; flushIndexes(indexes: IndexBatch): Promise; updateDividend(blockNumber: number, dividend: number | null, unitbase: number, local_iindex: IindexEntry[]): Promise; } export declare type StatName = "newcomers" | "certs" | "joiners" | "actives" | "leavers" | "revoked" | "excluded" | "ud" | "tx";