chaindb: more cases for genesis block.

This commit is contained in:
Christopher Jeffrey 2017-07-09 13:12:21 -07:00
parent e65f6e26c3
commit 0ffabd7a9a
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

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