Skip to content
Draft
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**: 41
**Total Functions**: 40

## Table of Contents

Expand All @@ -31,13 +31,12 @@ Functions: 3

### Configuration

Functions: 17
Functions: 16

| 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_clear_peers` | Removes all configured peers from the configuration This is useful when the... | config |
| `dash_spv_ffi_config_destroy` | Destroys an FFIClientConfig and frees its memory # Safety - `config` must... | config |
| `dash_spv_ffi_config_get_network` | Gets the network type from the configuration # Safety - `config` must be a... | config |
| `dash_spv_ffi_config_mainnet` | No description | config |
Expand Down Expand Up @@ -202,22 +201,6 @@ Adds a peer address to the configuration Accepts socket addresses with or witho

---

#### `dash_spv_ffi_config_clear_peers`

```c
dash_spv_ffi_config_clear_peers(config: *mut FFIClientConfig) -> i32
```

**Description:**
Removes all configured peers from the configuration This is useful when the caller wants to start with a clean slate before adding custom peers via `dash_spv_ffi_config_add_peer`. # Safety - `config` must be a valid pointer to an FFIClientConfig created by dash_spv_ffi_config_new/mainnet/testnet - The caller must ensure the config pointer remains valid for the duration of this call

**Safety:**
- `config` must be a valid pointer to an FFIClientConfig created by dash_spv_ffi_config_new/mainnet/testnet - The caller must ensure the config pointer remains valid for the duration of this call

**Module:** `config`

---

#### `dash_spv_ffi_config_destroy`

```c
Expand Down
17 changes: 0 additions & 17 deletions dash-spv-ffi/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,23 +166,6 @@ pub unsafe extern "C" fn dash_spv_ffi_config_add_peer(
}
}

/// Removes all configured peers from the configuration
///
/// This is useful when the caller wants to start with a clean slate
/// before adding custom peers via `dash_spv_ffi_config_add_peer`.
///
/// # Safety
/// - `config` must be a valid pointer to an FFIClientConfig created by dash_spv_ffi_config_new/mainnet/testnet
/// - The caller must ensure the config pointer remains valid for the duration of this call
#[no_mangle]
pub unsafe extern "C" fn dash_spv_ffi_config_clear_peers(config: *mut FFIClientConfig) -> i32 {
null_check!(config);

let cfg = unsafe { &mut *((*config).inner as *mut ClientConfig) };
cfg.peers.clear();
FFIErrorCode::Success as i32
}

/// Sets the user agent string to advertise in the P2P handshake
///
/// # Safety
Expand Down
33 changes: 0 additions & 33 deletions dash-spv-ffi/tests/test_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,39 +94,6 @@ mod tests {
}
}

#[test]
#[serial]
fn test_config_clear_peers() {
unsafe {
let config = dash_spv_ffi_config_new(FFINetwork::Testnet);

// Add peers
let peer1 = CString::new("127.0.0.1:9999").unwrap();
let peer2 = CString::new("127.0.0.2:9999").unwrap();
dash_spv_ffi_config_add_peer(config, peer1.as_ptr());
dash_spv_ffi_config_add_peer(config, peer2.as_ptr());

// Clear all peers
let result = dash_spv_ffi_config_clear_peers(config);
assert_eq!(result, FFIErrorCode::Success as i32);

// Clear on already-empty should still succeed
let result = dash_spv_ffi_config_clear_peers(config);
assert_eq!(result, FFIErrorCode::Success as i32);

dash_spv_ffi_config_destroy(config);
}
}

#[test]
#[serial]
fn test_config_clear_peers_null() {
unsafe {
let result = dash_spv_ffi_config_clear_peers(std::ptr::null_mut());
assert_eq!(result, FFIErrorCode::NullPointer as i32);
}
}

#[test]
#[serial]
fn test_config_user_agent() {
Expand Down
Loading