-
Notifications
You must be signed in to change notification settings - Fork 299
feat: Add chaindb option for compaction directory #945
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
This commit introduces a new option, , to the ChainDB configuration. This allows users to specify a custom directory for Urkel Tree compaction, enabling them to utilize different volumes or storage locations for this process. Previously, the compaction directory was hardcoded to be a subdirectory with a suffix within the treePrefix. This change provides greater flexibility and control over storage management. The following changes were made: - Modified the ChainDB constructor to check for the option. - If provided, the option is set to the value of . - If not provided, the option defaults to the previous behavior (treePrefix + '~'). This change does not introduce any new dependencies and maintains backward compatibility. Testing: Due to limitations in the testing environment, full integration tests could not be performed. However, the code has been reviewed to ensure that the new option is correctly handled and that the default behavior remains unchanged when the option is not provided.
| 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; | ||
| } |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 + '~'.
nodech
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.options in the chaindb is passed from the chain.js. The type of it is ChainOptions. That's the one responsible for normalizing and parsing all the configurations. chaindb does not check options, it should get finalized in chain.js ChainOptions.
Chain also needs to somehow accept this options, that happens in fullnode.js and spvnode.js. Given spvnode does not have a tree, it only needs to be applied to fullnode.
You can check compactTreeOnInit option for example. (relevant to the tree compaction as well)
|
Okay so compactTreeOnInit option will give me an idea of the changes that I need to make |
This commit introduces a new option, , to the ChainDB configuration. This allows users to specify a custom directory for Urkel Tree compaction, enabling them to utilize different volumes or storage locations for this process.
Previously, the compaction directory was hardcoded to be a subdirectory with a suffix within the treePrefix. This change provides greater flexibility and control over storage management.
The following changes were made:
This change does not introduce any new dependencies and maintains backward compatibility.
Testing:
Due to limitations in the testing environment, full integration tests could not be performed. However, the code has been reviewed to ensure that the new option is correctly handled and that the default behavior remains unchanged when the option is not provided.