UNPKG

4.09 kBTypeScriptView Raw
1/// <reference types="node" />
2/// <reference types="pouchdb-core" />
3import { ECPoint } from '@neo-one/client-common';
4import { Block, Blockchain as BlockchainType, CallReceipt, ConsensusPayload, Header, Input, InvocationTransaction, Settings, Storage, Transaction, VerifyTransactionResult, VM } from '@neo-one/node-core';
5import BN from 'bn.js';
6import { Observable } from 'rxjs';
7export interface CreateBlockchainOptions {
8 readonly settings: Settings;
9 readonly storage: Storage;
10 readonly vm: VM;
11}
12export interface BlockchainOptions extends CreateBlockchainOptions {
13 readonly currentBlock: BlockchainType['currentBlock'] | undefined;
14 readonly previousBlock: BlockchainType['previousBlock'] | undefined;
15 readonly currentHeader: BlockchainType['currentHeader'] | undefined;
16}
17export declare class Blockchain {
18 static create({ settings, storage, vm }: CreateBlockchainOptions): Promise<BlockchainType>;
19 readonly deserializeWireContext: BlockchainType['deserializeWireContext'];
20 readonly serializeJSONContext: BlockchainType['serializeJSONContext'];
21 readonly feeContext: BlockchainType['feeContext'];
22 private readonly settings$;
23 private readonly storage;
24 private mutableCurrentBlock;
25 private mutablePreviousBlock;
26 private mutableCurrentHeader;
27 private mutablePersistingBlocks;
28 private mutableBlockQueue;
29 private mutableInQueue;
30 private readonly vm;
31 private mutableRunning;
32 private mutableDoneRunningResolve;
33 private mutableBlock$;
34 constructor(options: BlockchainOptions);
35 readonly settings: Settings;
36 readonly currentBlock: Block;
37 readonly previousBlock: Block | undefined;
38 readonly currentHeader: Header;
39 readonly currentBlockIndex: number;
40 readonly block$: Observable<Block>;
41 readonly isPersistingBlock: boolean;
42 readonly account: BlockchainType['account'];
43 readonly accountUnclaimed: BlockchainType['accountUnclaimed'];
44 readonly accountUnspent: BlockchainType['accountUnspent'];
45 readonly action: BlockchainType['action'];
46 readonly asset: BlockchainType['asset'];
47 readonly block: BlockchainType['block'];
48 readonly blockData: BlockchainType['blockData'];
49 readonly header: BlockchainType['header'];
50 readonly transaction: BlockchainType['transaction'];
51 readonly transactionData: BlockchainType['transactionData'];
52 readonly output: BlockchainType['output'];
53 readonly contract: BlockchainType['contract'];
54 readonly storageItem: BlockchainType['storageItem'];
55 readonly validator: BlockchainType['validator'];
56 readonly invocationData: BlockchainType['invocationData'];
57 readonly validatorsCount: BlockchainType['validatorsCount'];
58 stop(): Promise<void>;
59 updateSettings(settings: Settings): void;
60 persistBlock({ block, unsafe, }: {
61 readonly block: Block;
62 readonly unsafe?: boolean;
63 }): Promise<void>;
64 persistHeaders(_headers: readonly Header[]): Promise<void>;
65 verifyBlock(block: Block): Promise<void>;
66 verifyConsensusPayload(payload: ConsensusPayload): Promise<void>;
67 verifyTransaction({ transaction, memPool, }: {
68 readonly transaction: Transaction;
69 readonly memPool?: readonly Transaction[];
70 }): Promise<VerifyTransactionResult>;
71 invokeScript(script: Buffer): Promise<CallReceipt>;
72 invokeTransaction(transaction: InvocationTransaction): Promise<CallReceipt>;
73 reset(): Promise<void>;
74 readonly getValidators: (transactions: readonly Transaction[]) => Promise<readonly ECPoint[]>;
75 readonly calculateClaimAmount: (claims: readonly Input[]) => Promise<BN>;
76 private persistBlocksAsync;
77 private cleanBlockQueue;
78 private dequeBlockQueue;
79 private readonly verifyScript;
80 private readonly tryGetInvocationData;
81 private readonly tryGetTransactionData;
82 private readonly getUnclaimed;
83 private readonly getUnspent;
84 private readonly getAllValidators;
85 private readonly isSpent;
86 private readonly tryGetSpentCoin;
87 private start;
88 private persistBlockInternal;
89 private createWriteBlockchain;
90}