-
Notifications
You must be signed in to change notification settings - Fork 11
feat: add functions to update client configuration and enable masternodes #130
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 |
|---|---|---|
|
|
@@ -339,6 +339,41 @@ impl FFIDashSpvClient { | |
| } | ||
| } | ||
|
|
||
| /// Update the running client's configuration. | ||
| /// | ||
| /// # Safety | ||
| /// - `client` must be a valid pointer to an `FFIDashSpvClient`. | ||
| /// - `config` must be a valid pointer to an `FFIClientConfig`. | ||
| /// - The network in `config` must match the client's network; changing networks at runtime is not supported. | ||
| #[no_mangle] | ||
| pub unsafe extern "C" fn dash_spv_ffi_client_update_config( | ||
| client: *mut FFIDashSpvClient, | ||
| config: *const FFIClientConfig, | ||
| ) -> i32 { | ||
| null_check!(client); | ||
| null_check!(config); | ||
|
|
||
| let client = &(*client); | ||
| let new_config = (&*config).clone_inner(); | ||
|
|
||
| let result = client.runtime.block_on(async { | ||
| let mut guard = client.inner.lock().unwrap(); | ||
| if let Some(ref mut spv_client) = *guard { | ||
| spv_client.update_config(new_config).await.map_err(|e| e) | ||
| } else { | ||
| Err(dash_spv::SpvError::Config("Client not initialized".to_string())) | ||
| } | ||
| }); | ||
|
|
||
| match result { | ||
| Ok(()) => FFIErrorCode::Success as i32, | ||
| Err(e) => { | ||
| set_last_error(&e.to_string()); | ||
| FFIErrorCode::from(e) as i32 | ||
| } | ||
| } | ||
| } | ||
|
Comment on lines
+342
to
+375
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. 💡 Verification agent ❓ Verification inconclusiveAdd a unit test for dash_spv_ffi_client_update_config. Per prior guidance, each new FFI should have a unit test under dash-spv-ffi/tests. Validate success path and “client not initialized”. Run to check for tests: 🏁 Script executed: #!/bin/bash
rg -nP --glob 'dash-spv-ffi/tests/**' '(client_update_config|dash_spv_ffi_client_update_config)'Length of output: 98 Add Rust and C tests for 🤖 Prompt for AI Agents |
||
|
|
||
| #[no_mangle] | ||
| pub unsafe extern "C" fn dash_spv_ffi_client_start(client: *mut FFIDashSpvClient) -> i32 { | ||
| null_check!(client); | ||
|
|
||
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.
💡 Verification agent
🧩 Analysis chain
Update-config API: document blocking behavior and enforce network invariants
Callers need to know this is synchronous (blocks on runtime). Also please verify a hard check rejects network changes at this boundary.
Doc tweak:
To verify the invariant is enforced, run:
Also confirm unit tests exist for both new FFI functions under dash-spv-ffi/tests.
Finally, regenerate this header and sync to swift-dash-core-sdk (./sync-headers.sh).
🏁 Script executed:
Length of output: 5280
🏁 Script executed:
rg -n 'dash_spv_ffi_client_update_config|dash_spv_ffi_config_set_masternode_sync_enabled' dash-spv-ffi/testsLength of output: 110
🏁 Script executed:
Length of output: 120
🏁 Script executed:
Length of output: 897
Update header docs and add missing FFI tests
* - The network in `config` must match the client's network; changing networks at runtime is not supported. + * - This call is synchronous and blocks until the reconfiguration is applied; avoid calling on UI threads.📝 Committable suggestion
🤖 Prompt for AI Agents