chain: compact db after pruning.
This commit is contained in:
parent
d9c7d7e874
commit
028fee9eee
@ -748,6 +748,8 @@ ChainDB.prototype.prune = co(function* prune(tip) {
|
||||
throw e;
|
||||
}
|
||||
|
||||
yield this.db.compactRange();
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
|
||||
@ -401,14 +401,20 @@ LowlevelUp.prototype.approximateSize = function approximateSize(start, end) {
|
||||
|
||||
/**
|
||||
* Compact range of keys.
|
||||
* @param {String|Buffer} start - Start key.
|
||||
* @param {String|Buffer} end - End key.
|
||||
* @param {String|Buffer|null} start - Start key.
|
||||
* @param {String|Buffer|null} end - End key.
|
||||
* @returns {Promise}
|
||||
*/
|
||||
|
||||
LowlevelUp.prototype.compactRange = function compactRange(start, end) {
|
||||
var self = this;
|
||||
|
||||
if (!start)
|
||||
start = new Buffer([0x00]);
|
||||
|
||||
if (!end)
|
||||
end = new Buffer([0xff]);
|
||||
|
||||
return new Promise(function(resolve, reject) {
|
||||
if (!self.loaded) {
|
||||
reject(new Error('Database is closed.'));
|
||||
@ -416,7 +422,7 @@ LowlevelUp.prototype.compactRange = function compactRange(start, end) {
|
||||
}
|
||||
|
||||
if (!self.binding.compactRange) {
|
||||
reject(new Error('Cannot compact range.'));
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user