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

Commit 87ec3a4

Browse files
committed
Fix validation flags handling
1 parent b9854e4 commit 87ec3a4

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/index.ts

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

9595
/**
96-
* This the flag indicates if blocks and Proof-of-Work should be validated. Defaults to true.
96+
* This the flag indicates if blocks and Proof-of-Work should be validated.
9797
* This option can't be used in conjunction with `validatePow` nor `validateBlocks`.
9898
*
9999
* @deprecated
@@ -102,13 +102,15 @@ export interface BlockchainOptions {
102102

103103
/**
104104
* This flags indicates if Proof-of-work should be validated. If `validate` is provided, this
105-
* option takes its value.
105+
* option takes its value. If neither `validate` nor this option are provided, it defaults to
106+
* `true`.
106107
*/
107108
validatePow?: boolean
108109

109110
/**
110111
* This flags indicates if blocks should be validated. See Block#validate for details. If
111-
* `validate` is provided, this option takes its value.
112+
* `validate` is provided, this option takes its value. If neither `validate` nor this option are
113+
* provided, it defaults to `true`.
112114
*/
113115
validateBlocks?: boolean
114116
}
@@ -208,12 +210,12 @@ export default class Blockchain implements BlockchainInterface {
208210

209211
// defaults
210212

211-
if (opts.validate) {
212-
this._validatePow = true
213-
this._validateBlocks = true
213+
if (opts.validate !== undefined) {
214+
this._validatePow = opts.validate
215+
this._validateBlocks = opts.validate
214216
} else {
215-
this._validatePow = opts.validatePow !== undefined ? opts.validatePow : false
216-
this._validateBlocks = opts.validateBlocks !== undefined ? opts.validateBlocks : false
217+
this._validatePow = opts.validatePow !== undefined ? opts.validatePow : true
218+
this._validateBlocks = opts.validateBlocks !== undefined ? opts.validateBlocks : true
217219
}
218220

219221
this.db = opts.db ? opts.db : level()

0 commit comments

Comments
 (0)