Skip to content
This repository was archived by the owner on Apr 6, 2020. It is now read-only.

Commit 11bb191

Browse files
committed
Split BlockchainOptions#validate into two values
1 parent 3c1445f commit 11bb191

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

src/index.ts

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,21 @@ export interface BlockchainOptions {
9393
db?: any
9494

9595
/**
96-
* This the flag indicates if blocks should be validated (e.g. Proof-of-Work), latest HF rules
97-
* supported: `Petersburg`.
96+
* This the flag indicates if blocks and Proof-of-Work should be validated. Defaults to true.
97+
* See
9898
*/
9999
validate?: boolean
100+
101+
/**
102+
* This flags indicates if Proof-of-work should be validated. Defaults to the value of `validate`.
103+
*/
104+
validatePow?: boolean
105+
106+
/**
107+
* This flags indicates if blocks should be validated. See Block#validate for details. Defaults to
108+
* the value of `validate`.
109+
*/
110+
validateBlocks?: boolean
100111
}
101112

102113
/**
@@ -162,6 +173,9 @@ export default class Blockchain implements BlockchainInterface {
162173
*/
163174
validate: boolean
164175

176+
private readonly _validatePow: boolean
177+
private readonly _validateBlocks: boolean
178+
165179
/**
166180
* Creates new Blockchain object
167181
*
@@ -183,6 +197,8 @@ export default class Blockchain implements BlockchainInterface {
183197
this.db = opts.db ? opts.db : level()
184198
this.dbManager = new DBManager(this.db, this._common)
185199
this.validate = opts.validate === undefined ? true : opts.validate
200+
this._validatePow = opts.validatePow !== undefined ? opts.validatePow : this.validate
201+
this._validateBlocks = opts.validateBlocks !== undefined ? opts.validateBlocks : this.validate
186202
this.ethash = this.validate ? new Ethash(this.db) : null
187203
this._heads = {}
188204
this._genesis = null
@@ -444,7 +460,7 @@ export default class Blockchain implements BlockchainInterface {
444460
)
445461

446462
function verify(next: any) {
447-
if (!self.validate) {
463+
if (!self._validateBlocks) {
448464
return next()
449465
}
450466

@@ -456,7 +472,7 @@ export default class Blockchain implements BlockchainInterface {
456472
}
457473

458474
function verifyPOW(next: any) {
459-
if (!self.validate) {
475+
if (!self._validatePow) {
460476
return next()
461477
}
462478

0 commit comments

Comments
 (0)