chaindb: recovery.
This commit is contained in:
parent
c950a30330
commit
ef51f4f842
@ -742,7 +742,12 @@ ChainDB.prototype._init = function _init() {
|
|||||||
|
|
||||||
this.size = this.getSize();
|
this.size = this.getSize();
|
||||||
|
|
||||||
assert(this.size % BLOCK_SIZE === 0);
|
if (this.size % BLOCK_SIZE !== 0) {
|
||||||
|
utils.debug('Blockchain is at an odd length. Truncating.');
|
||||||
|
fs.truncateSync(this.file, this.size - (this.size % BLOCK_SIZE));
|
||||||
|
this.size = this.getSize();
|
||||||
|
assert(this.size % BLOCK_SIZE === 0);
|
||||||
|
}
|
||||||
|
|
||||||
this.fd = fs.openSync(this.file, 'r+');
|
this.fd = fs.openSync(this.file, 'r+');
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user