From 5e1d8c743c16d55e38e551a474a4dca9b8b56c2d Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Sat, 28 Jan 2017 19:29:16 -0800 Subject: [PATCH] chain: add genesis check. --- lib/blockchain/chain.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/blockchain/chain.js b/lib/blockchain/chain.js index c78e6f22..91d4b3aa 100644 --- a/lib/blockchain/chain.js +++ b/lib/blockchain/chain.js @@ -1143,6 +1143,12 @@ Chain.prototype._add = co(function* add(block) { // Mark the start time. this.mark(); + // Special case for genesis block. + if (hash === this.network.genesis.hash) { + this.emit('exists', block, block.getCoinbaseHeight()); + throw new VerifyError(block, 'duplicate', 'duplicate', 0); + } + // Do we already have this block in the queue? if (this.hasPending(hash)) { this.emit('exists', block, block.getCoinbaseHeight());