Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion lib/blockchain/chaindb.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Comment on lines +66 to +73
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the difference between compactionDirectory and customCompactionDirectory?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

customCompactionDirectory is the user-provided option, while compactionDirectory is what the system actually uses. If the user provides a custom directory, we use that; otherwise, it defaults to treePrefix + '~'.


this.db = bdb.create(this.options);
this.name = 'chain';
this.version = 3;
Expand Down Expand Up @@ -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,
Expand Down
Loading