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;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
yield this.db.compactRange();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -401,14 +401,20 @@ LowlevelUp.prototype.approximateSize = function approximateSize(start, end) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Compact range of keys.
|
* Compact range of keys.
|
||||||
* @param {String|Buffer} start - Start key.
|
* @param {String|Buffer|null} start - Start key.
|
||||||
* @param {String|Buffer} end - End key.
|
* @param {String|Buffer|null} end - End key.
|
||||||
* @returns {Promise}
|
* @returns {Promise}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
LowlevelUp.prototype.compactRange = function compactRange(start, end) {
|
LowlevelUp.prototype.compactRange = function compactRange(start, end) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
|
if (!start)
|
||||||
|
start = new Buffer([0x00]);
|
||||||
|
|
||||||
|
if (!end)
|
||||||
|
end = new Buffer([0xff]);
|
||||||
|
|
||||||
return new Promise(function(resolve, reject) {
|
return new Promise(function(resolve, reject) {
|
||||||
if (!self.loaded) {
|
if (!self.loaded) {
|
||||||
reject(new Error('Database is closed.'));
|
reject(new Error('Database is closed.'));
|
||||||
@ -416,7 +422,7 @@ LowlevelUp.prototype.compactRange = function compactRange(start, end) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!self.binding.compactRange) {
|
if (!self.binding.compactRange) {
|
||||||
reject(new Error('Cannot compact range.'));
|
resolve();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user