-
Notifications
You must be signed in to change notification settings - Fork 10
Clean/remove memory storage #275
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 2 commits
25f5700
8b2f417
6ce3a96
33c0eac
19a4b80
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 |
|---|---|---|
|
|
@@ -307,65 +307,29 @@ async fn run() -> Result<(), Box<dyn std::error::Error>> { | |
| } | ||
| }; | ||
|
|
||
| // Create and start the client based on storage type | ||
| if config.enable_persistence { | ||
| if let Some(path) = &config.storage_path { | ||
| let storage_manager = | ||
| match dash_spv::storage::DiskStorageManager::new(path.clone()).await { | ||
| Ok(sm) => sm, | ||
| Err(e) => { | ||
| eprintln!("Failed to create disk storage manager: {}", e); | ||
| process::exit(1); | ||
| } | ||
| }; | ||
| run_client( | ||
| config, | ||
| network_manager, | ||
| storage_manager, | ||
| wallet, | ||
| enable_terminal_ui, | ||
| &matches, | ||
| wallet_id, | ||
| ) | ||
| .await?; | ||
| } else { | ||
| let storage_manager = match dash_spv::storage::MemoryStorageManager::new().await { | ||
| Ok(sm) => sm, | ||
| Err(e) => { | ||
| eprintln!("Failed to create memory storage manager: {}", e); | ||
| process::exit(1); | ||
| } | ||
| }; | ||
| run_client( | ||
| config, | ||
| network_manager, | ||
| storage_manager, | ||
| wallet, | ||
| enable_terminal_ui, | ||
| &matches, | ||
| wallet_id, | ||
| ) | ||
| .await?; | ||
| } | ||
| let path = if let Some(path) = &config.storage_path { | ||
| path.clone() | ||
| } else { | ||
| let storage_manager = match dash_spv::storage::MemoryStorageManager::new().await { | ||
| Ok(sm) => sm, | ||
| Err(e) => { | ||
| eprintln!("Failed to create memory storage manager: {}", e); | ||
| process::exit(1); | ||
| } | ||
| }; | ||
| run_client( | ||
| config, | ||
| network_manager, | ||
| storage_manager, | ||
| wallet, | ||
| enable_terminal_ui, | ||
| &matches, | ||
| wallet_id, | ||
| ) | ||
| .await?; | ||
| } | ||
| "./.tmp/main-exec-storage".into() | ||
| }; | ||
|
|
||
| let storage_manager = match dash_spv::storage::DiskStorageManager::new(path.clone()).await { | ||
xdustinface marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Ok(sm) => sm, | ||
| Err(e) => { | ||
| eprintln!("Failed to create disk storage manager: {}", e); | ||
| process::exit(1); | ||
| } | ||
| }; | ||
|
Comment on lines
+310
to
+322
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. 🧩 Analysis chain🏁 Script executed: # First, let's understand the config structure and with_storage_path method
rg -n "with_storage_path" dash-spv/src --type rs -A 5 -B 2Repository: dashpay/rust-dashcore Length of output: 91 🏁 Script executed: # Check the config.storage_path field definition
rg -n "storage_path" dash-spv/src/client/config.rs -B 2 -A 2Repository: dashpay/rust-dashcore Length of output: 630 🏁 Script executed: # Examine the main.rs code flow around lines 183-320 to trace storage_path
sed -n '183,320p' dash-spv/src/main.rs | cat -nRepository: dashpay/rust-dashcore Length of output: 5974 🏁 Script executed: # Check DiskStorageManager::new signature
rg -n "impl DiskStorageManager" dash-spv/src/storage -A 10Repository: dashpay/rust-dashcore Length of output: 3356 🏁 Script executed: # Find the validate() method implementation in config.rs
rg -n "fn validate" dash-spv/src/client/config.rs -A 20Repository: dashpay/rust-dashcore Length of output: 886 🏁 Script executed: # Check if storage_path is modified after being set with_storage_path
rg -n "storage_path" dash-spv/src/main.rs -B 2 -A 2Repository: dashpay/rust-dashcore Length of output: 377 🏁 Script executed: # Check the actual line numbers in main.rs to confirm the code snippet
sed -n '230,260p' dash-spv/src/main.rs | cat -nRepository: dashpay/rust-dashcore Length of output: 1332 Remove the unreachable fallback path that violates coding guidelines. The - let path = if let Some(path) = &config.storage_path {
- path.clone()
- } else {
- "./.tmp/main-exec-storage".into()
- };
-
- let storage_manager = match dash_spv::storage::DiskStorageManager::new(path.clone()).await {
+ let storage_path = config.storage_path.clone()
+ .expect("storage_path must be set via with_storage_path");
+
+ let storage_manager = match dash_spv::storage::DiskStorageManager::new(storage_path).await {🤖 Prompt for AI Agents |
||
| run_client( | ||
| config, | ||
| network_manager, | ||
| storage_manager, | ||
| wallet, | ||
| enable_terminal_ui, | ||
| &matches, | ||
| wallet_id, | ||
| ) | ||
| .await?; | ||
|
|
||
| Ok(()) | ||
| } | ||
|
|
||
This file was deleted.
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.
Should probably use the proper temp dir constructor here and probably good to log the temp dir then.
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.
The constructor is only available in the unit test since it is marked with cfg(test), tempdir is a dev-dependency and i didnt want to modify it
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.
Okay then at least have a separate directory for each example. There is also the third "with wallet" example that could be aligned with those changes but thats a separate issue i guess.