-
Notifications
You must be signed in to change notification settings - Fork 11
feat(dash-spv-ffi): expose MasternodeListEngine accessor on FFIDashSpvClient #607
Description
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
FFIDashSpvClientstruct:dash-spv-ffi/src/client.rs:26innerfield:pub(crate) inner: InnerClient(line 27)- Platform PR using this: feat(swift-sdk): use SPV-synced quorums for Platform proof verification platform#3417