import { BlockDTO } from "../../../lib/dto/BlockDTO"; import { DBBlock } from "../../../lib/db/DBBlock"; import { PeerDTO } from "../../../lib/dto/PeerDTO"; import { BranchingDTO } from "../../../lib/dto/ConfDTO"; export declare abstract class PullingDao { abstract applyBranch(blocks: BlockDTO[]): Promise; abstract localCurrent(): Promise; abstract remoteCurrent(source?: any): Promise; abstract remotePeers(source?: any): Promise; abstract getLocalBlock(number: number): Promise; abstract getRemoteBlock(thePeer: PeerDTO, number: number): Promise; abstract applyMainBranch(block: BlockDTO): Promise; abstract removeForks(): Promise; abstract isMemberPeer(thePeer: PeerDTO): Promise; abstract downloadBlocks(thePeer: PeerDTO, fromNumber: number, count?: number): Promise; } export declare abstract class AbstractDAO extends PullingDao { /** * Sugar function. Apply a bunch of blocks instead of one. * @param blocks */ applyBranch(blocks: BlockDTO[]): Promise; /** * Binary search algorithm to find the common root block between a local and a remote blockchain. * @param fork An object containing a peer, its current block and top fork block * @param forksize The maximum length we can look at to find common root block. * @returns {*|Promise} */ findCommonRoot(fork: any, forksize: number): Promise; static defaultLocalBlock(): DBBlock; /** * Pull algorithm. Look at given peers' blockchain and try to pull blocks from it. * May lead local blockchain to fork. * @param conf The local node configuration * @param dao An abstract layer to retrieve peers data (blocks). * @param logger Logger of the main application. */ pull(conf: BranchingDTO, logger: any): Promise; }