diff --git a/dash-spv-ffi/FFI_API.md b/dash-spv-ffi/FFI_API.md index d87b92a76..043c69396 100644 --- a/dash-spv-ffi/FFI_API.md +++ b/dash-spv-ffi/FFI_API.md @@ -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 @@ -13,7 +13,6 @@ This document provides a comprehensive reference for all FFI (Foreign Function I - [Synchronization](#synchronization) - [Address Monitoring](#address-monitoring) - [Transaction Management](#transaction-management) -- [Mempool Operations](#mempool-operations) - [Platform Integration](#platform-integration) - [Event Callbacks](#event-callbacks) - [Error Handling](#error-handling) @@ -95,14 +94,6 @@ Functions: 3 | `dash_spv_ffi_unconfirmed_transaction_destroy` | Destroys an FFIUnconfirmedTransaction and all its associated resources #... | types | | `dash_spv_ffi_unconfirmed_transaction_destroy_raw_tx` | Destroys the raw transaction bytes allocated for an FFIUnconfirmedTransaction... | types | -### Mempool Operations - -Functions: 1 - -| Function | Description | Module | -|----------|-------------|--------| -| `dash_spv_ffi_client_enable_mempool_tracking` | Enable mempool tracking with a given strategy | client | - ### Platform Integration Functions: 4 @@ -776,24 +767,6 @@ Destroys the raw transaction bytes allocated for an FFIUnconfirmedTransaction # --- -### Mempool Operations - Detailed - -#### `dash_spv_ffi_client_enable_mempool_tracking` - -```c -dash_spv_ffi_client_enable_mempool_tracking(client: *mut FFIDashSpvClient, strategy: FFIMempoolStrategy,) -> i32 -``` - -**Description:** -Enable mempool tracking with a given strategy. # Safety - `client` must be a valid, non-null pointer. - -**Safety:** -- `client` must be a valid, non-null pointer. - -**Module:** `client` - ---- - ### Platform Integration - Detailed #### `ffi_dash_spv_get_core_handle` diff --git a/dash-spv-ffi/include/dash_spv_ffi.h b/dash-spv-ffi/include/dash_spv_ffi.h index 4fcf2e12d..934b2597c 100644 --- a/dash-spv-ffi/include/dash_spv_ffi.h +++ b/dash-spv-ffi/include/dash_spv_ffi.h @@ -29,17 +29,17 @@ typedef enum FFISyncStage { Failed = 9, } FFISyncStage; -typedef enum FFIMempoolStrategy { - FetchAll = 0, - BloomFilter = 1, -} FFIMempoolStrategy; - typedef enum DashSpvValidationMode { None = 0, Basic = 1, Full = 2, } DashSpvValidationMode; +typedef enum FFIMempoolStrategy { + FetchAll = 0, + BloomFilter = 1, +} FFIMempoolStrategy; + typedef struct FFIDashSpvClient FFIDashSpvClient; /** @@ -482,17 +482,6 @@ int32_t dash_spv_ffi_client_rescan_blockchain(struct FFIDashSpvClient *client, uint32_t _from_height) ; -/** - * Enable mempool tracking with a given strategy. - * - * # Safety - * - `client` must be a valid, non-null pointer. - */ - -int32_t dash_spv_ffi_client_enable_mempool_tracking(struct FFIDashSpvClient *client, - enum FFIMempoolStrategy strategy) -; - /** * Record that we attempted to send a transaction by its txid. * diff --git a/dash-spv-ffi/src/client.rs b/dash-spv-ffi/src/client.rs index 8848d188b..f444762fe 100644 --- a/dash-spv-ffi/src/client.rs +++ b/dash-spv-ffi/src/client.rs @@ -1,6 +1,6 @@ use crate::{ null_check, set_last_error, FFIClientConfig, FFIDetailedSyncProgress, FFIErrorCode, - FFIEventCallbacks, FFIMempoolStrategy, FFISpvStats, FFISyncProgress, FFIWalletManager, + FFIEventCallbacks, FFISpvStats, FFISyncProgress, FFIWalletManager, }; // Import wallet types from key-wallet-ffi use key_wallet_ffi::FFIWalletManager as KeyWalletFFIWalletManager; @@ -1253,49 +1253,6 @@ pub unsafe extern "C" fn dash_spv_ffi_client_rescan_blockchain( } } -/// Enable mempool tracking with a given strategy. -/// -/// # Safety -/// - `client` must be a valid, non-null pointer. -#[no_mangle] -pub unsafe extern "C" fn dash_spv_ffi_client_enable_mempool_tracking( - client: *mut FFIDashSpvClient, - strategy: FFIMempoolStrategy, -) -> i32 { - null_check!(client); - - let client = &(*client); - let inner = client.inner.clone(); - - let mempool_strategy = strategy.into(); - - let result = client.runtime.block_on(async { - let mut spv_client = { - let mut guard = inner.lock().unwrap(); - match guard.take() { - Some(client) => client, - None => { - return Err(dash_spv::SpvError::Storage(dash_spv::StorageError::NotFound( - "Client not initialized".to_string(), - ))) - } - } - }; - let res = spv_client.enable_mempool_tracking(mempool_strategy).await; - let mut guard = 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 - } - } -} - /// Record that we attempted to send a transaction by its txid. /// /// # Safety diff --git a/dash-spv/src/client/mempool.rs b/dash-spv/src/client/mempool.rs index fac807360..1568dd0a2 100644 --- a/dash-spv/src/client/mempool.rs +++ b/dash-spv/src/client/mempool.rs @@ -15,33 +15,9 @@ use crate::network::NetworkManager; use crate::storage::StorageManager; use key_wallet_manager::wallet_interface::WalletInterface; -use super::{config, DashSpvClient}; +use super::DashSpvClient; impl DashSpvClient { - /// Enable mempool tracking with the specified strategy. - pub async fn enable_mempool_tracking( - &mut self, - strategy: config::MempoolStrategy, - ) -> Result<()> { - // Update config - self.config.enable_mempool_tracking = true; - self.config.mempool_strategy = strategy; - - // Initialize mempool filter if not already done - if self.mempool_filter.is_none() { - // TODO: Get monitored addresses from wallet - self.mempool_filter = Some(Arc::new(MempoolFilter::new( - self.config.mempool_strategy, - self.config.max_mempool_transactions, - self.mempool_state.clone(), - HashSet::new(), // Will be populated from wallet's monitored addresses - self.config.network, - ))); - } - - Ok(()) - } - /// Get mempool balance for an address. pub async fn get_mempool_balance( &self, diff --git a/dash-spv/src/client/mod.rs b/dash-spv/src/client/mod.rs index bd6be889d..db658c2fc 100644 --- a/dash-spv/src/client/mod.rs +++ b/dash-spv/src/client/mod.rs @@ -123,16 +123,10 @@ mod tests { let test_address = Address::dummy(config.network, 0); - let mut client = DashSpvClient::new(config, network_manager, storage, wallet) + let client = DashSpvClient::new(config, network_manager, storage, wallet) .await .expect("client construction must succeed"); - // Enable mempool tracking to initialize mempool_filter - client - .enable_mempool_tracking(crate::client::config::MempoolStrategy::BloomFilter) - .await - .expect("enable mempool tracking must succeed"); - // Create a transaction that sends 10 Dash to the test address let tx = Transaction { version: 2,