From 0ffabd7a9a7f78fa02488340042b3d41d4327caa Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Sun, 9 Jul 2017 13:12:21 -0700 Subject: [PATCH] chaindb: more cases for genesis block. --- lib/blockchain/chaindb.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/blockchain/chaindb.js b/lib/blockchain/chaindb.js index ec1e5962..c560c108 100644 --- a/lib/blockchain/chaindb.js +++ b/lib/blockchain/chaindb.js @@ -1329,7 +1329,8 @@ ChainDB.prototype._save = async function save(entry, block, view) { } // Hash->next-block index. - this.put(layout.n(entry.prevBlock), hash); + if (!entry.isGenesis()) + this.put(layout.n(entry.prevBlock), hash); // Height->hash index. this.put(layout.H(entry.height), hash); @@ -1375,6 +1376,8 @@ ChainDB.prototype.reconnect = async function reconnect(entry, block, view) { ChainDB.prototype._reconnect = async function reconnect(entry, block, view) { let hash = block.hash(); + assert(!entry.isGenesis()); + // We can now add a hash->next-block index. this.put(layout.n(entry.prevBlock), hash);