From 0580d2274f2ad40422b05f23a143d9ca7e9a77ba Mon Sep 17 00:00:00 2001 From: garrettmills Date: Sat, 10 Apr 2021 21:08:19 -0500 Subject: [PATCH] Fid Blockchain.validate for genesis blocks --- src/app/units/Blockchain.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/app/units/Blockchain.ts b/src/app/units/Blockchain.ts index 0e46cdf..5bd5215 100644 --- a/src/app/units/Blockchain.ts +++ b/src/app/units/Blockchain.ts @@ -272,6 +272,10 @@ export class Blockchain extends Unit { const blocks = collect(chain) return ( await blocks.promiseMap(async (block, idx) => { + if ( await block.isGenesis() ) { + return true + } + const previous: Block | undefined = blocks.at(idx - 1) if ( !previous ) { this.logging.debug(`Chain is invalid: block ${idx} is missing previous ${idx - 1}.`) @@ -295,10 +299,6 @@ export class Blockchain extends Unit { return false } - if ( await block.isGenesis() ) { - return true - } - if ( !(await this.validateProofOfWork(block, previous)) ) { this.logging.debug(`Chain is invalid: block ${idx} failed proof of work validation`) return false;