From 397df0324576076d92ed23f9a3a3fa82c11fbce2 Mon Sep 17 00:00:00 2001 From: "aleksei.voronin" <aleksei.voronin@demlabs.net> Date: Wed, 27 May 2020 11:28:23 +0300 Subject: [PATCH] [+] new option to set default chain for transactions --- modules/mempool/dap_chain_mempool.c | 7 ++++++- modules/net/dap_chain_net.c | 6 ++++++ modules/net/include/dap_chain_net.h | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/modules/mempool/dap_chain_mempool.c b/modules/mempool/dap_chain_mempool.c index be05de54de..8cc95901e3 100644 --- a/modules/mempool/dap_chain_mempool.c +++ b/modules/mempool/dap_chain_mempool.c @@ -657,7 +657,12 @@ dap_chain_hash_fast_t* dap_chain_proc_tx_create_cond(dap_chain_net_t * a_net, dap_chain_net_srv_uid_t a_srv_uid, uint64_t a_value_fee, const void *a_cond, size_t a_cond_size) { - dap_chain_t *l_chain = dap_chain_net_get_chain_by_chain_type(a_net, CHAIN_TYPE_TX); + dap_chain_t *l_chain = NULL; + if(a_net->pub.default_tx_chain) + l_chain = a_net->pub.default_tx_chain; + else + dap_chain_net_get_chain_by_chain_type(a_net, CHAIN_TYPE_TX); + if(!l_chain) return NULL; // Make transfer transaction diff --git a/modules/net/dap_chain_net.c b/modules/net/dap_chain_net.c index 2ccacb4614..c5c52f1baa 100644 --- a/modules/net/dap_chain_net.c +++ b/modules/net/dap_chain_net.c @@ -1661,6 +1661,12 @@ int s_net_load(const char * a_net_name) } dap_list_free(l_prior_list); + const char* l_default_tx_chain_name = dap_config_get_item_str(l_cfg , "general" , "default_tx_chain"); + if(l_default_tx_chain_name) + l_net->pub.default_tx_chain = dap_chain_net_get_chain_by_name(l_net, l_default_tx_chain_name); + else + l_net->pub.default_tx_chain = NULL; + } else { log_it(L_ERROR,"Can't any chains for network %s",l_net->pub.name); PVT(l_net)->load_mode = false; diff --git a/modules/net/include/dap_chain_net.h b/modules/net/include/dap_chain_net.h index b11b20a150..d174d83a27 100644 --- a/modules/net/include/dap_chain_net.h +++ b/modules/net/include/dap_chain_net.h @@ -75,6 +75,7 @@ typedef struct dap_chain_net{ char * gdb_nodes; dap_chain_t * chains; // double-linked list of chains + dap_chain_t * default_tx_chain; dap_ledger_t *ledger; } pub; uint8_t pvt[]; -- GitLab