UNPKG

@neo-one/node-blockchain-esnext-esm

Version:

NEO•ONE NEO blockchain implementation.

90 lines (89 loc) 4.01 kB
/// <reference types="node" /> import { ECPoint } from '@neo-one/client-common-esnext-esm'; import { Block, Blockchain as BlockchainType, CallReceipt, ConsensusPayload, Header, Input, InvocationTransaction, Settings, Storage, Transaction, VerifyTransactionResult, VM } from '@neo-one/node-core-esnext-esm'; import BN from 'bn.js'; import { Observable } from 'rxjs'; export interface CreateBlockchainOptions { readonly settings: Settings; readonly storage: Storage; readonly vm: VM; } export interface BlockchainOptions extends CreateBlockchainOptions { readonly currentBlock: BlockchainType['currentBlock'] | undefined; readonly previousBlock: BlockchainType['previousBlock'] | undefined; readonly currentHeader: BlockchainType['currentHeader'] | undefined; } export declare class Blockchain { static create({ settings, storage, vm }: CreateBlockchainOptions): Promise<BlockchainType>; readonly deserializeWireContext: BlockchainType['deserializeWireContext']; readonly serializeJSONContext: BlockchainType['serializeJSONContext']; readonly feeContext: BlockchainType['feeContext']; private readonly settings$; private readonly storage; private mutableCurrentBlock; private mutablePreviousBlock; private mutableCurrentHeader; private mutablePersistingBlocks; private mutableBlockQueue; private mutableInQueue; private readonly vm; private mutableRunning; private mutableDoneRunningResolve; private mutableBlock$; constructor(options: BlockchainOptions); get settings(): Settings; get currentBlock(): Block; get previousBlock(): Block | undefined; get currentHeader(): Header; get currentBlockIndex(): number; get block$(): Observable<Block>; get isPersistingBlock(): boolean; get account(): BlockchainType['account']; get accountUnclaimed(): BlockchainType['accountUnclaimed']; get accountUnspent(): BlockchainType['accountUnspent']; get action(): BlockchainType['action']; get asset(): BlockchainType['asset']; get block(): BlockchainType['block']; get blockData(): BlockchainType['blockData']; get header(): BlockchainType['header']; get transaction(): BlockchainType['transaction']; get transactionData(): BlockchainType['transactionData']; get output(): BlockchainType['output']; get contract(): BlockchainType['contract']; get storageItem(): BlockchainType['storageItem']; get validator(): BlockchainType['validator']; get invocationData(): BlockchainType['invocationData']; get validatorsCount(): BlockchainType['validatorsCount']; stop(): Promise<void>; updateSettings(settings: Settings): void; persistBlock({ block, unsafe, }: { readonly block: Block; readonly unsafe?: boolean; }): Promise<void>; persistHeaders(_headers: readonly Header[]): Promise<void>; verifyBlock(block: Block): Promise<void>; verifyConsensusPayload(payload: ConsensusPayload): Promise<void>; verifyTransaction({ transaction, memPool, }: { readonly transaction: Transaction; readonly memPool?: readonly Transaction[]; }): Promise<VerifyTransactionResult>; invokeScript(script: Buffer): Promise<CallReceipt>; invokeTransaction(transaction: InvocationTransaction): Promise<CallReceipt>; reset(): Promise<void>; readonly getValidators: (transactions: readonly Transaction[]) => Promise<readonly ECPoint[]>; readonly calculateClaimAmount: (claims: readonly Input[]) => Promise<BN>; private persistBlocksAsync; private cleanBlockQueue; private dequeBlockQueue; private readonly verifyScript; private readonly tryGetInvocationData; private readonly tryGetTransactionData; private readonly getUnclaimed; private readonly getUnspent; private readonly getAllValidators; private readonly isSpent; private readonly tryGetSpentCoin; private start; private persistBlockInternal; private createWriteBlockchain; }