diff --git a/lib/bcoin/chain.js b/lib/bcoin/chain.js index 38bcd569..4970f21f 100644 --- a/lib/bcoin/chain.js +++ b/lib/bcoin/chain.js @@ -735,6 +735,9 @@ ChainDB.prototype._init = function _init() { } this.size = this.getSize(); + + assert(this.size % BLOCK_SIZE === 0); + this.fd = fs.openSync(this.file, 'r+'); }; @@ -764,7 +767,7 @@ ChainDB.prototype.getSize = function getSize() { ChainDB.prototype.count = function count() { var len = this.size / BLOCK_SIZE; - assert(len === (len | 0)); + assert(len % 1 === 0); return len; };