diff --git a/lib/blockchain/chaindb.js b/lib/blockchain/chaindb.js index 6c0f07cda..6d6468a4c 100644 --- a/lib/blockchain/chaindb.js +++ b/lib/blockchain/chaindb.js @@ -63,6 +63,15 @@ class ChainDB { this.logger = this.options.logger.context('chaindb'); this.blocks = options.blocks; + if (this.options.compactionDirectory == null) { + this.options.compactionDirectory = this.options.treePrefix + '~'; + } + + // Allow users to specify a custom compaction directory + if (options.customCompactionDirectory != null) { + this.options.compactionDirectory = options.customCompactionDirectory; + } + this.db = bdb.create(this.options); this.name = 'chain'; this.version = 3; @@ -1020,7 +1029,7 @@ class ChainDB { )); await this.commit(); - const tmpDir = this.options.treePrefix + '~'; + const tmpDir = this.options.compactionDirectory; const tmpTree = new Tree({ hash: blake2b,