return chainwork correctly for genesis block.

This commit is contained in:
Christopher Jeffrey 2016-02-19 22:41:43 -08:00
parent e2759707f2
commit 2fd490922b
2 changed files with 5 additions and 3 deletions

View File

@ -58,7 +58,7 @@ ChainBlock.prototype.getChainwork = function getChainwork() {
// Workaround for genesis block // Workaround for genesis block
// being added _in_ chaindb. // being added _in_ chaindb.
if (!this.chain.db) if (!this.chain.db)
return; return this.getProof();
prev = this.prev; prev = this.prev;

View File

@ -359,7 +359,8 @@ ChainDB.prototype.saveSync = function saveSync(entry) {
assert(entry.height >= 0); assert(entry.height >= 0);
if (entry.height * BLOCK_SIZE !== this.size) { if (entry.height * BLOCK_SIZE !== this.size) {
utils.debug('Warning attempt to write to height: %d/%d', this.height); utils.debug('Warning attempt to write to height: %d/%d',
entry.height, this.getSize() - 1);
return false; return false;
} }
@ -385,7 +386,8 @@ ChainDB.prototype.saveAsync = function saveAsync(entry, callback) {
assert(entry.height >= 0); assert(entry.height >= 0);
if (entry.height * BLOCK_SIZE !== this.size) { if (entry.height * BLOCK_SIZE !== this.size) {
utils.debug('Warning attempt to write to height: %d/%d', this.height); utils.debug('Warning attempt to write to height: %d/%d',
entry.height, this.getSize() - 1);
return callback(); return callback();
} }