Summary
FFIDashSpvClient.inner is currently pub(crate), which prevents external crates (like rs-sdk-ffi in the platform repo) from accessing the MasternodeListEngine directly. This forces a round-trip through C-style FFI functions (ffi_dash_spv_get_quorum_public_key) even when calling from Rust code in the same binary.
What's needed
Add a public accessor on FFIDashSpvClient that returns the masternode list engine:
impl FFIDashSpvClient {
/// Returns the shared masternode list engine, if initialized.
pub fn masternode_list_engine(&self) -> Option<Arc<RwLock<MasternodeListEngine>>> {
self.inner.masternode_list_engine().ok()
}
/// Returns the network this client is configured for.
pub fn network(&self) -> Network {
self.runtime.block_on(async { self.inner.network().await })
}
}
Why
Platform repo has a pure-Rust SpvContextProvider in platform-wallet (PR #3417) that implements the ContextProvider trait by reading quorum data directly from Arc<RwLock<MasternodeListEngine>> — zero FFI. But currently the FFI bridge in rs-sdk-ffi can't use it because it can't extract the engine from FFIDashSpvClient.
Once this accessor exists, rs-sdk-ffi can replace its FFI bridge with:
let engine = ffi_client.masternode_list_engine().expect("not initialized");
let network = ffi_client.network();
let provider = platform_wallet::SpvContextProvider::new(engine, network);
sdk_builder.with_context_provider(provider);
Context
Summary
FFIDashSpvClient.inneris currentlypub(crate), which prevents external crates (likers-sdk-ffiin the platform repo) from accessing theMasternodeListEnginedirectly. This forces a round-trip through C-style FFI functions (ffi_dash_spv_get_quorum_public_key) even when calling from Rust code in the same binary.What's needed
Add a public accessor on
FFIDashSpvClientthat returns the masternode list engine:Why
Platform repo has a pure-Rust
SpvContextProviderinplatform-wallet(PR #3417) that implements theContextProvidertrait by reading quorum data directly fromArc<RwLock<MasternodeListEngine>>— zero FFI. But currently the FFI bridge inrs-sdk-ffican't use it because it can't extract the engine fromFFIDashSpvClient.Once this accessor exists,
rs-sdk-ffican replace its FFI bridge with:Context
FFIDashSpvClientstruct:dash-spv-ffi/src/client.rs:26innerfield:pub(crate) inner: InnerClient(line 27)