Skip to content

Commit e69741b

Browse files
committed
ffi setters are back with deprecated warning to encorage new API while maintaining compatibility with the old one
1 parent d9b01bf commit e69741b

File tree

7 files changed

+966
-56
lines changed

7 files changed

+966
-56
lines changed

dash-spv-ffi/FFI_API.md

Lines changed: 302 additions & 14 deletions
Large diffs are not rendered by default.

dash-spv-ffi/dash_spv_ffi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ int32_t dash_spv_ffi_config_set_masternode_sync_enabled(struct FFIClientConfig *
698698
* - If null or no data directory is set, returns an FFIString with null pointer
699699
* - The returned FFIString must be freed by the caller using `dash_spv_ffi_string_destroy`
700700
*/
701-
struct FFIString dash_spv_ffi_config_get_storage_path(const struct FFIClientConfig *config) ;
701+
struct FFIString dash_spv_ffi_config_get_data_dir(const struct FFIClientConfig *config) ;
702702

703703
/**
704704
* Destroys an FFIClientConfig and frees its memory

dash-spv-ffi/include/dash_spv_ffi.h

Lines changed: 192 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,49 @@ struct FFIClientConfig *dash_spv_ffi_config_builder_build(struct FFIClientConfig
739739
void dash_spv_ffi_config_builder_destroy(struct FFIClientConfigBuilder *builder)
740740
;
741741

742+
struct FFIClientConfig *dash_spv_ffi_config_new(FFINetwork network) ;
743+
744+
struct FFIClientConfig *dash_spv_ffi_config_mainnet(void) ;
745+
746+
struct FFIClientConfig *dash_spv_ffi_config_testnet(void) ;
747+
748+
/**
749+
* Sets the data directory for storing blockchain data
750+
*
751+
* # Safety
752+
* - `config` must be a valid pointer to an FFIClientConfig created by dash_spv_ffi_config_new/mainnet/testnet
753+
* - `path` must be a valid null-terminated C string
754+
* - The caller must ensure the config pointer remains valid for the duration of this call
755+
*/
756+
757+
int32_t dash_spv_ffi_config_set_data_dir(struct FFIClientConfig *config,
758+
const char *path)
759+
;
760+
761+
/**
762+
* Sets the validation mode for the SPV client
763+
*
764+
* # Safety
765+
* - `config` must be a valid pointer to an FFIClientConfig created by dash_spv_ffi_config_new/mainnet/testnet
766+
* - The caller must ensure the config pointer remains valid for the duration of this call
767+
*/
768+
769+
int32_t dash_spv_ffi_config_set_validation_mode(struct FFIClientConfig *config,
770+
enum DashSpvValidationMode mode)
771+
;
772+
773+
/**
774+
* Sets the maximum number of peers to connect to
775+
*
776+
* # Safety
777+
* - `config` must be a valid pointer to an FFIClientConfig created by dash_spv_ffi_config_new/mainnet/testnet
778+
* - The caller must ensure the config pointer remains valid for the duration of this call
779+
*/
780+
781+
int32_t dash_spv_ffi_config_set_max_peers(struct FFIClientConfig *config,
782+
uint32_t max_peers)
783+
;
784+
742785
/**
743786
* Adds a peer address to the configuration
744787
*
@@ -752,17 +795,77 @@ void dash_spv_ffi_config_builder_destroy(struct FFIClientConfigBuilder *builder)
752795
* - Hostname without port: `node.example.com`
753796
*
754797
* # Safety
755-
* - `config` must be a valid pointer to an FFIConfig
798+
* - `config` must be a valid pointer to an FFIClientConfig
756799
* - `addr` must be a valid null-terminated C string containing a socket address or IP-only string
757800
* - The caller must ensure both pointers remain valid for the duration of this call
758801
*/
759802
int32_t dash_spv_ffi_config_add_peer(struct FFIClientConfig *config, const char *addr) ;
760803

804+
/**
805+
* Sets the user agent string to advertise in the P2P handshake
806+
*
807+
* # Safety
808+
* - `config` must be a valid pointer to an FFIClientConfig created by dash_spv_ffi_config_new/mainnet/testnet
809+
* - `user_agent` must be a valid null-terminated C string
810+
* - The caller must ensure both pointers remain valid for the duration of this call
811+
*/
812+
813+
int32_t dash_spv_ffi_config_set_user_agent(struct FFIClientConfig *config,
814+
const char *user_agent)
815+
;
816+
817+
/**
818+
* Sets whether to relay transactions (currently a no-op)
819+
*
820+
* # Safety
821+
* - `config` must be a valid pointer to an FFIClientConfig created by dash_spv_ffi_config_new/mainnet/testnet
822+
* - The caller must ensure the config pointer remains valid for the duration of this call
823+
*/
824+
825+
int32_t dash_spv_ffi_config_set_relay_transactions(struct FFIClientConfig *config,
826+
bool _relay)
827+
;
828+
829+
/**
830+
* Sets whether to load bloom filters
831+
*
832+
* # Safety
833+
* - `config` must be a valid pointer to an FFIClientConfig created by dash_spv_ffi_config_new/mainnet/testnet
834+
* - The caller must ensure the config pointer remains valid for the duration of this call
835+
*/
836+
837+
int32_t dash_spv_ffi_config_set_filter_load(struct FFIClientConfig *config,
838+
bool load_filters)
839+
;
840+
841+
/**
842+
* Restrict connections strictly to configured peers (disable DNS discovery and peer store)
843+
*
844+
* # Safety
845+
* - `config` must be a valid pointer to an FFIClientConfig created by dash_spv_ffi_config_new/mainnet/testnet
846+
*/
847+
848+
int32_t dash_spv_ffi_config_set_restrict_to_configured_peers(struct FFIClientConfig *config,
849+
bool restrict_peers)
850+
;
851+
852+
/**
853+
* Enables or disables masternode synchronization
854+
*
855+
* # Safety
856+
* - `config` must be a valid pointer to an FFIClientConfig created by dash_spv_ffi_config_new/mainnet/testnet
857+
* - The caller must ensure the config pointer remains valid for the duration of this call
858+
*/
859+
860+
int32_t dash_spv_ffi_config_set_masternode_sync_enabled(struct FFIClientConfig *config,
861+
bool enable)
862+
;
863+
761864
/**
762865
* Gets the network type from the configuration
763866
*
764867
* # Safety
765-
* - `config` must be a valid pointer to an FFIConfig or null
868+
* - `config` must be a valid pointer to an FFIClientConfig or null
766869
* - If null, returns FFINetwork::Dash as default
767870
*/
768871
FFINetwork dash_spv_ffi_config_get_network(const struct FFIClientConfig *config) ;
@@ -771,11 +874,89 @@ void dash_spv_ffi_config_builder_destroy(struct FFIClientConfigBuilder *builder)
771874
* Gets the data directory path from the configuration
772875
*
773876
* # Safety
774-
* - `config` must be a valid pointer to an FFIConfig or null
877+
* - `config` must be a valid pointer to an FFIClientConfig or null
775878
* - If null or no data directory is set, returns an FFIString with null pointer
776879
* - The returned FFIString must be freed by the caller using `dash_spv_ffi_string_destroy`
777880
*/
778-
struct FFIString dash_spv_ffi_config_get_storage_path(const struct FFIClientConfig *config) ;
881+
struct FFIString dash_spv_ffi_config_get_data_dir(const struct FFIClientConfig *config) ;
882+
883+
/**
884+
* Destroys an FFIClientConfig and frees its memory
885+
*
886+
* # Safety
887+
* - `config` must be a valid pointer to an FFIClientConfig or null
888+
* - After calling this function, the config pointer becomes invalid and must not be used
889+
* - This function should only be called once per config instance
890+
*/
891+
void dash_spv_ffi_config_destroy(struct FFIClientConfig *config) ;
892+
893+
/**
894+
* Sets the number of Tokio worker threads for the FFI runtime (0 = auto)
895+
*
896+
* # Safety
897+
* - `config` must be a valid pointer to an FFIClientConfig
898+
*/
899+
int32_t dash_spv_ffi_config_set_worker_threads(struct FFIClientConfig *config, uint32_t threads) ;
900+
901+
/**
902+
* Enables or disables mempool tracking
903+
*
904+
* # Safety
905+
* - `config` must be a valid pointer to an FFIClientConfig created by dash_spv_ffi_config_new/mainnet/testnet
906+
* - The caller must ensure the config pointer remains valid for the duration of this call
907+
*/
908+
909+
int32_t dash_spv_ffi_config_set_mempool_tracking(struct FFIClientConfig *config,
910+
bool enable)
911+
;
912+
913+
/**
914+
* Sets the mempool synchronization strategy
915+
*
916+
* # Safety
917+
* - `config` must be a valid pointer to an FFIClientConfig created by dash_spv_ffi_config_new/mainnet/testnet
918+
* - The caller must ensure the config pointer remains valid for the duration of this call
919+
*/
920+
921+
int32_t dash_spv_ffi_config_set_mempool_strategy(struct FFIClientConfig *config,
922+
enum FFIMempoolStrategy strategy)
923+
;
924+
925+
/**
926+
* Sets the maximum number of mempool transactions to track
927+
*
928+
* # Safety
929+
* - `config` must be a valid pointer to an FFIClientConfig created by dash_spv_ffi_config_new/mainnet/testnet
930+
* - The caller must ensure the config pointer remains valid for the duration of this call
931+
*/
932+
933+
int32_t dash_spv_ffi_config_set_max_mempool_transactions(struct FFIClientConfig *config,
934+
uint32_t max_transactions)
935+
;
936+
937+
/**
938+
* Sets whether to fetch full mempool transaction data
939+
*
940+
* # Safety
941+
* - `config` must be a valid pointer to an FFIClientConfig created by dash_spv_ffi_config_new/mainnet/testnet
942+
* - The caller must ensure the config pointer remains valid for the duration of this call
943+
*/
944+
945+
int32_t dash_spv_ffi_config_set_fetch_mempool_transactions(struct FFIClientConfig *config,
946+
bool fetch)
947+
;
948+
949+
/**
950+
* Sets whether to persist mempool state to disk
951+
*
952+
* # Safety
953+
* - `config` must be a valid pointer to an FFIClientConfig created by dash_spv_ffi_config_new/mainnet/testnet
954+
* - The caller must ensure the config pointer remains valid for the duration of this call
955+
*/
956+
957+
int32_t dash_spv_ffi_config_set_persist_mempool(struct FFIClientConfig *config,
958+
bool persist)
959+
;
779960

780961
/**
781962
* Gets whether mempool tracking is enabled
@@ -798,14 +979,16 @@ enum FFIMempoolStrategy dash_spv_ffi_config_get_mempool_strategy(const struct FF
798979
;
799980

800981
/**
801-
* Destroys an FFIConfig and frees its memory
982+
* Sets the starting block height for synchronization
802983
*
803984
* # Safety
804-
* - `builder` must be a valid pointer to an FFIConfigBuilder, or null
805-
* - After calling this function, the config pointer becomes invalid and must not be used
806-
* - This function should only be called once per config instance
985+
* - `config` must be a valid pointer to an FFIClientConfig created by dash_spv_ffi_config_new/mainnet/testnet
986+
* - The caller must ensure the config pointer remains valid for the duration of this call
807987
*/
808-
void dash_spv_ffi_config_destroy(struct FFIClientConfig *config) ;
988+
989+
int32_t dash_spv_ffi_config_set_start_from_height(struct FFIClientConfig *config,
990+
uint32_t height)
991+
;
809992

810993
const char *dash_spv_ffi_get_last_error(void) ;
811994

0 commit comments

Comments
 (0)