@rei-network/blockchain
Advanced tools
Comparing version 1.1.1 to 1.1.2
/// <reference types="bn.js" /> | ||
/// <reference types="node" /> | ||
import { Address, BN } from 'ethereumjs-util'; | ||
export declare type CliqueSignerState = [BN, Address[]]; | ||
export declare type CliqueLatestSignerStates = CliqueSignerState[]; | ||
export declare type CliqueVote = [BN, [Address, Address, Buffer]]; | ||
export declare type CliqueLatestVotes = CliqueVote[]; | ||
export declare type CliqueBlockSigner = [BN, Address]; | ||
export declare type CliqueLatestBlockSigners = CliqueBlockSigner[]; | ||
export type CliqueSignerState = [BN, Address[]]; | ||
export type CliqueLatestSignerStates = CliqueSignerState[]; | ||
export type CliqueVote = [BN, [Address, Address, Buffer]]; | ||
export type CliqueLatestVotes = CliqueVote[]; | ||
export type CliqueBlockSigner = [BN, Address]; | ||
export type CliqueLatestBlockSigners = CliqueBlockSigner[]; | ||
export declare const CLIQUE_NONCE_AUTH: Buffer; | ||
export declare const CLIQUE_NONCE_DROP: Buffer; |
@@ -7,3 +7,3 @@ /// <reference types="node" /> | ||
import { Database } from '@rei-network/database'; | ||
declare type OnBlock = (block: Block, reorg: boolean) => Promise<void> | void; | ||
type OnBlock = (block: Block, reorg: boolean) => Promise<void> | void; | ||
export interface PutBlockOptions { | ||
@@ -10,0 +10,0 @@ receipts?: Receipt[]; |
@@ -20,2 +20,33 @@ "use strict"; | ||
/** | ||
* Safe creation of a new Blockchain object awaiting the initialization function, | ||
* encouraged method to use when creating a blockchain object. | ||
* | ||
* @param opts Constructor options, see {@link BlockchainOptions} | ||
*/ | ||
static async create(opts) { | ||
const blockchain = new Blockchain(opts); | ||
await blockchain.initPromise.catch((e) => { | ||
throw e; | ||
}); | ||
return blockchain; | ||
} | ||
/** | ||
* Creates a blockchain from a list of block objects, | ||
* objects must be readable by {@link Block.fromBlockData} | ||
* | ||
* @param blockData List of block objects | ||
* @param opts Constructor options, see {@link BlockchainOptions} | ||
*/ | ||
static async fromBlocksData(blocksData, opts) { | ||
const blockchain = await Blockchain.create(opts); | ||
for (const blockData of blocksData) { | ||
const block = structure_1.Block.fromBlockData(blockData, { | ||
common: blockchain._common, | ||
hardforkByBlockNumber: true | ||
}); | ||
await blockchain.putBlock(block); | ||
} | ||
return blockchain; | ||
} | ||
/** | ||
* Creates new Blockchain object | ||
@@ -113,33 +144,2 @@ * | ||
/** | ||
* Safe creation of a new Blockchain object awaiting the initialization function, | ||
* encouraged method to use when creating a blockchain object. | ||
* | ||
* @param opts Constructor options, see {@link BlockchainOptions} | ||
*/ | ||
static async create(opts) { | ||
const blockchain = new Blockchain(opts); | ||
await blockchain.initPromise.catch((e) => { | ||
throw e; | ||
}); | ||
return blockchain; | ||
} | ||
/** | ||
* Creates a blockchain from a list of block objects, | ||
* objects must be readable by {@link Block.fromBlockData} | ||
* | ||
* @param blockData List of block objects | ||
* @param opts Constructor options, see {@link BlockchainOptions} | ||
*/ | ||
static async fromBlocksData(blocksData, opts) { | ||
const blockchain = await Blockchain.create(opts); | ||
for (const blockData of blocksData) { | ||
const block = structure_1.Block.fromBlockData(blockData, { | ||
common: blockchain._common, | ||
hardforkByBlockNumber: true | ||
}); | ||
await blockchain.putBlock(block); | ||
} | ||
return blockchain; | ||
} | ||
/** | ||
* Returns an object with metadata about the Blockchain. It's defined for | ||
@@ -146,0 +146,0 @@ * backwards compatibility. |
{ | ||
"name": "@rei-network/blockchain", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"main": "dist/index.js", | ||
@@ -17,5 +17,5 @@ "types": "dist/index.d.ts", | ||
"dependencies": { | ||
"@rei-network/common": "^1.1.1", | ||
"@rei-network/database": "^1.1.1", | ||
"@rei-network/structure": "^0.1.3", | ||
"@rei-network/common": "^1.1.2", | ||
"@rei-network/database": "^1.1.2", | ||
"@rei-network/structure": "^0.1.4", | ||
"debug": "^4.3.3", | ||
@@ -22,0 +22,0 @@ "ethereumjs-util": "^7.1.4", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
174254
Updated@rei-network/common@^1.1.2
Updated@rei-network/database@^1.1.2