Skip to content
Closed
Show file tree
Hide file tree
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
21 changes: 2 additions & 19 deletions dash-spv-ffi/FFI_API.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This document provides a comprehensive reference for all FFI (Foreign Function I

**Auto-generated**: This documentation is automatically generated from the source code. Do not edit manually.

**Total Functions**: 67
**Total Functions**: 66

## Table of Contents

Expand Down Expand Up @@ -34,11 +34,10 @@ Functions: 4

### Configuration

Functions: 25
Functions: 24

| Function | Description | Module |
|----------|-------------|--------|
| `dash_spv_ffi_client_update_config` | Update the running client's configuration | client |
| `dash_spv_ffi_config_add_peer` | Adds a peer address to the configuration Accepts socket addresses with or... | config |
| `dash_spv_ffi_config_destroy` | Destroys an FFIClientConfig and frees its memory # Safety - `config` must... | config |
| `dash_spv_ffi_config_get_data_dir` | Gets the data directory path from the configuration # Safety - `config`... | config |
Expand Down Expand Up @@ -228,22 +227,6 @@ Stop the SPV client. # Safety - `client` must be a valid, non-null pointer to a

### Configuration - Detailed

#### `dash_spv_ffi_client_update_config`

```c
dash_spv_ffi_client_update_config(client: *mut FFIDashSpvClient, config: *const FFIClientConfig,) -> i32
```

**Description:**
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.

**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.

**Module:** `client`

---

#### `dash_spv_ffi_config_add_peer`

```c
Expand Down
13 changes: 0 additions & 13 deletions dash-spv-ffi/include/dash_spv_ffi.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,19 +293,6 @@ struct FFIArray dash_spv_ffi_checkpoints_between_heights(FFINetwork network,
*/
int32_t dash_spv_ffi_client_drain_events(struct FFIDashSpvClient *client) ;

/**
* 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.
*/

int32_t dash_spv_ffi_client_update_config(struct FFIDashSpvClient *client,
const struct FFIClientConfig *config)
;

/**
* Start the SPV client.
*
Expand Down
46 changes: 0 additions & 46 deletions dash-spv-ffi/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,52 +417,6 @@ fn stop_client_internal(client: &mut FFIDashSpvClient) -> Result<(), dash_spv::S
result
}

/// 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 {
// Take client without holding the lock across await
let mut spv_client = {
let mut guard = client.inner.lock().unwrap();
match guard.take() {
Some(client) => client,
None => {
return Err(dash_spv::SpvError::Config("Client not initialized".to_string()))
}
}
};

let res = spv_client.update_config(new_config).await;

// Put client back
let mut guard = client.inner.lock().unwrap();
*guard = Some(spv_client);
res
});

match result {
Ok(()) => FFIErrorCode::Success as i32,
Err(e) => {
set_last_error(&e.to_string());
FFIErrorCode::from(e) as i32
}
}
}

/// Start the SPV client.
///
/// # Safety
Expand Down
18 changes: 0 additions & 18 deletions dash-spv/src/client/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,24 +264,6 @@ impl<W: WalletInterface, N: NetworkManager, S: StorageManager> DashSpvClient<W,
Ok(())
}

// ============ Configuration ============

/// Update the client configuration.
pub async fn update_config(&mut self, new_config: ClientConfig) -> Result<()> {
// Validate new configuration
new_config.validate().map_err(SpvError::Config)?;

// Ensure network hasn't changed
if new_config.network != self.config.network {
return Err(SpvError::Config("Cannot change network on running client".to_string()));
}

// Update configuration
self.config = new_config;

Ok(())
}

// ============ Terminal UI ============

/// Enable terminal UI for status display.
Expand Down
Loading