Grow LmDB with GB increment

This commit is contained in:
Jaco Greeff
2019-03-05 11:30:03 +01:00
parent 1bb8674206
commit c85a727e9f
+6 -6
View File
@@ -38,19 +38,19 @@ export default class LmDb implements BaseDb {
});
}
private getMapSize (): number {
private getNextMapSize (): number {
const dbsize = this.size();
const max = Math.ceil(dbsize / GB) * GB;
const remaining = (max - dbsize) / GB;
const mapSize = this._env.info().mapSize;
const remaining = (mapSize - dbsize) / GB;
return (remaining < 0.25)
? max + 1
: max;
? (mapSize + GB)
: mapSize;
}
private growMapSize (): void {
const info = this._env.info();
const next = this.getMapSize();
const next = this.getNextMapSize();
if (next > info.mapSize) {
l.debug(() => `Growing mapsize to ${(next / GB).toFixed(1)}GB`);