-
Notifications
You must be signed in to change notification settings - Fork 9
refactor(dash-spv): Building storage from config #366
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,8 +34,8 @@ pub struct ClientConfig { | |
| /// If no peers are configured, no outbound connections will be made. | ||
| pub restrict_to_configured_peers: bool, | ||
|
|
||
| /// Optional path for persistent storage. | ||
| pub storage_path: Option<PathBuf>, | ||
| /// Path for persistent storage. Defaults to ./dash-spv-storage | ||
| pub storage_path: PathBuf, | ||
|
|
||
| /// Validation mode. | ||
| pub validation_mode: ValidationMode, | ||
|
|
@@ -80,7 +80,7 @@ impl Default for ClientConfig { | |
| network: Network::Dash, | ||
| peers: vec![], | ||
| restrict_to_configured_peers: false, | ||
| storage_path: None, | ||
| storage_path: PathBuf::from("./dash-spv-storage"), | ||
| validation_mode: ValidationMode::Full, | ||
|
Comment on lines
+83
to
84
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Default storage_path is network-agnostic; risk of cross-network data mixing. If callers use ClientConfig::testnet()/regtest() without overriding storage_path, multiple networks will share the same on-disk state directory. That can corrupt or misinterpret chain data. Consider deriving a network-specific default (e.g., 🤖 Prompt for AI Agents |
||
| enable_filters: true, | ||
| enable_masternodes: true, | ||
|
|
@@ -136,8 +136,8 @@ impl ClientConfig { | |
| } | ||
|
|
||
| /// Set storage path. | ||
| pub fn with_storage_path(mut self, path: PathBuf) -> Self { | ||
| self.storage_path = Some(path); | ||
| pub fn with_storage_path(mut self, path: impl Into<PathBuf>) -> Self { | ||
| self.storage_path = path.into(); | ||
| self | ||
| } | ||
|
|
||
|
|
@@ -206,6 +206,13 @@ impl ClientConfig { | |
| ); | ||
| } | ||
|
|
||
| std::fs::create_dir_all(&self.storage_path).map_err(|e| { | ||
| format!( | ||
| "A valid storage path must be provided to the ClientConfig {:?}: {e}", | ||
| self.storage_path | ||
| ) | ||
| })?; | ||
|
|
||
| Ok(()) | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.