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);