diff --git a/modules/chain/dap_chain_ledger.c b/modules/chain/dap_chain_ledger.c index 4beffb11864342c0209529190581ac6f85a8c69f..4f7f9349619f62ad360e18424c07de753d7d1f30 100644 --- a/modules/chain/dap_chain_ledger.c +++ b/modules/chain/dap_chain_ledger.c @@ -5523,22 +5523,23 @@ dap_list_t *dap_chain_ledger_get_list_tx_outs_with_val(dap_ledger_t *a_ledger, c switch (l_type) { case TX_ITEM_TYPE_OUT_OLD: { dap_chain_tx_out_old_t *l_out = (dap_chain_tx_out_old_t *)l_list_tmp->data; - if (!l_out->header.value || memcmp(a_addr_from, &l_out->addr, sizeof(dap_chain_addr_t))) { + if (!l_out->header.value || memcmp(a_addr_from, &l_out->addr, sizeof(dap_chain_addr_t))) continue; - } l_value = GET_256_FROM_64(l_out->header.value); } break; case TX_ITEM_TYPE_OUT: { dap_chain_tx_out_t *l_out = (dap_chain_tx_out_t *)l_list_tmp->data; - if ( IS_ZERO_256(l_out->header.value) || memcmp(a_addr_from, &l_out->addr, sizeof(dap_chain_addr_t))) { + if (memcmp(a_addr_from, &l_out->addr, sizeof(dap_chain_addr_t)) || + dap_strcmp(dap_chain_ledger_tx_get_token_ticker_by_hash(a_ledger, &l_tx_cur_hash), a_token_ticker) || + IS_ZERO_256(l_out->header.value)) continue; - } l_value = l_out->header.value; } break; case TX_ITEM_TYPE_OUT_EXT: { dap_chain_tx_out_ext_t *l_out_ext = (dap_chain_tx_out_ext_t *)l_list_tmp->data; - if (IS_ZERO_256(l_out_ext->header.value) || memcmp(a_addr_from, &l_out_ext->addr, sizeof(dap_chain_addr_t)) || - strcmp((char *)a_token_ticker, l_out_ext->token)) { + if (memcmp(a_addr_from, &l_out_ext->addr, sizeof(dap_chain_addr_t)) || + strcmp((char *)a_token_ticker, l_out_ext->token) || + IS_ZERO_256(l_out_ext->header.value) ) { continue; } l_value = l_out_ext->header.value; @@ -5552,6 +5553,7 @@ dap_list_t *dap_chain_ledger_get_list_tx_outs_with_val(dap_ledger_t *a_ledger, c if (!dap_chain_ledger_tx_hash_is_used_out_item (a_ledger, &l_tx_cur_hash, l_out_idx_tmp, NULL)) { dap_chain_tx_used_out_item_t *l_item = DAP_NEW_Z(dap_chain_tx_used_out_item_t); if ( !l_item ) { + log_it(L_CRITICAL, "Out of memory"); if (l_list_used_out) dap_list_free_full(l_list_used_out, NULL); dap_list_free(l_list_out_items); diff --git a/modules/consensus/esbocs/dap_chain_cs_esbocs.c b/modules/consensus/esbocs/dap_chain_cs_esbocs.c index fe59b002e2e6fd89b32ca2a2f95876a4c6da5462..19e03b1712fe749d9f38f6d4fb91c78853f20b10 100644 --- a/modules/consensus/esbocs/dap_chain_cs_esbocs.c +++ b/modules/consensus/esbocs/dap_chain_cs_esbocs.c @@ -106,7 +106,6 @@ DAP_STATIC_INLINE size_t s_get_esbocs_message_size(dap_chain_esbocs_message_t *a } static dap_chain_esbocs_session_t * s_session_items; -static dap_timerfd_t *s_session_cs_timer = NULL; typedef struct dap_chain_esbocs_pvt { // Base params @@ -483,17 +482,16 @@ static int s_callback_created(dap_chain_t *a_chain, dap_config_t *a_chain_net_cf log_it(L_INFO, "Init session for net:%s, chain:%s", a_chain->net_name, a_chain->name); DL_APPEND(s_session_items, l_session); - if (!s_session_cs_timer) { - s_session_cs_timer = dap_timerfd_start(1000, s_session_timer, NULL); - debug_if(l_esbocs_pvt->debug, L_MSG, "Consensus main timer is started"); - } + l_session->cs_timer = dap_timerfd_start(1000, s_session_timer, l_session); + debug_if(l_esbocs_pvt->debug, L_MSG, "Consensus main timer is started"); + DAP_CHAIN_PVT(a_chain)->cs_started = true; return 0; } bool dap_chain_esbocs_started() { - return s_session_cs_timer; + return s_session_items; } static uint256_t s_callback_get_minimum_fee(dap_chain_t *a_chain) @@ -520,8 +518,7 @@ static void s_callback_delete(dap_chain_cs_blocks_t *a_blocks) dap_chain_esbocs_session_t *l_session = l_esbocs->session; pthread_mutex_lock(&l_session->mutex); DL_DELETE(s_session_items, l_session); - if (!s_session_items) - dap_timerfd_delete_mt(s_session_cs_timer->worker, s_session_cs_timer->esocket_uuid); + dap_timerfd_delete_mt(l_session->cs_timer->worker, l_session->cs_timer->esocket_uuid); s_session_round_clear(l_session); dap_chain_esbocs_sync_item_t *l_sync_item, *l_sync_tmp; HASH_ITER(hh, l_session->sync_items, l_sync_item, l_sync_tmp) { @@ -1240,11 +1237,8 @@ static void s_session_proc_state(dap_chain_esbocs_session_t *a_session) static bool s_session_timer(void *a_arg) { - UNUSED(a_arg); - dap_chain_esbocs_session_t *l_session = NULL; - DL_FOREACH(s_session_items, l_session) { - s_session_proc_state(l_session); - } + dap_chain_esbocs_session_t *l_session = a_arg; + s_session_proc_state(l_session); return true; } diff --git a/modules/consensus/esbocs/include/dap_chain_cs_esbocs.h b/modules/consensus/esbocs/include/dap_chain_cs_esbocs.h index 963ff35b7d13376053f90aea19565316cd957616..7a95d9dbf44c46948e4ad5211081b1832d1b75b9 100644 --- a/modules/consensus/esbocs/include/dap_chain_cs_esbocs.h +++ b/modules/consensus/esbocs/include/dap_chain_cs_esbocs.h @@ -153,6 +153,7 @@ typedef struct dap_chain_esbocs_penalty_item { typedef struct dap_chain_esbocs_session { pthread_mutex_t mutex; + dap_timerfd_t *cs_timer; dap_chain_block_t *processing_candidate; dap_chain_t *chain; diff --git a/modules/mempool/dap_chain_mempool.c b/modules/mempool/dap_chain_mempool.c index 40ad34ae818bc4a2ca090ffc199abc854def6c19..574e66c30174ffd2912b4d072a45de19085b7c4d 100644 --- a/modules/mempool/dap_chain_mempool.c +++ b/modules/mempool/dap_chain_mempool.c @@ -1245,19 +1245,16 @@ void chain_mempool_proc(struct dap_http_simple *cl_st, void * arg) DAP_DEL_Z(a_key); } else *return_code = Http_Status_BadRequest; - } - else *return_code = Http_Status_BadRequest; + } else + *return_code = Http_Status_BadRequest; enc_http_delegate_delete(l_enc_delegate); - } - else *return_code = Http_Status_Unauthorized; + } else + *return_code = Http_Status_Unauthorized; - if(hdr_session_close_id && hdr_session_close_id->value && !strcmp(hdr_session_close_id->value, "yes")) { + if (hdr_session_close_id && !strcmp(hdr_session_close_id->value, "yes") && hdr_key_id) // close session - if(hdr_key_id && hdr_key_id->value) { - dap_enc_ks_delete(hdr_key_id->value); - } - } + dap_enc_ks_delete(hdr_key_id->value); } /** diff --git a/modules/net/dap_chain_net.c b/modules/net/dap_chain_net.c index 8d69af9d5f57689eabf2dd6353a331e716ae160a..0f2d178f161254498d78b5698727670ab5a758ea 100644 --- a/modules/net/dap_chain_net.c +++ b/modules/net/dap_chain_net.c @@ -2767,12 +2767,11 @@ int s_net_init(const char * a_net_name, uint16_t a_acl_idx) if(l_cfg_new) { list_priority *l_chain_prior = DAP_NEW_Z(list_priority); if (!l_chain_prior) { - log_it(L_CRITICAL, "Memory allocation error"); - DAP_DELETE (l_entry_name); + log_it(L_CRITICAL, "Memory allocation error"); + DAP_DELETE(l_entry_name); closedir(l_chains_dir); dap_config_close(l_cfg_new); dap_config_close(l_cfg); - closedir(l_chains_dir); return -1; } l_chain_prior->prior = dap_config_get_item_uint16_default(l_cfg_new, "chain", "load_priority", 100); @@ -3405,7 +3404,7 @@ bool dap_chain_net_get_flag_sync_from_zero( dap_chain_net_t * a_net) */ bool dap_chain_net_get_extra_gdb_group(dap_chain_net_t *a_net, dap_chain_node_addr_t a_node_addr) { - if(!a_net || !PVT(a_net) || !PVT(a_net)->gdb_sync_nodes_addrs) + if (!a_net || !PVT(a_net)->gdb_sync_nodes_addrs) return false; for(uint16_t i = 0; i < PVT(a_net)->gdb_sync_nodes_addrs_count; i++) { if(a_node_addr.uint64 == PVT(a_net)->gdb_sync_nodes_addrs[i].uint64) { diff --git a/modules/net/srv/include/dap_chain_net_srv_order.h b/modules/net/srv/include/dap_chain_net_srv_order.h index db9ab023e0494fd1a5a51de13e6ab74bb625bad9..46e12790aa8bc11a8bac3874a6c2d926757a419e 100644 --- a/modules/net/srv/include/dap_chain_net_srv_order.h +++ b/modules/net/srv/include/dap_chain_net_srv_order.h @@ -129,7 +129,7 @@ char *dap_chain_net_srv_order_create(dap_chain_net_t * a_net, dap_chain_hash_fast_t a_tx_cond_hash, // Hash index of conditioned transaction attached with order uint256_t *a_price, // service price in datoshi, for SERV_CLASS_ONCE ONCE for the whole service, for SERV_CLASS_PERMANENT for one unit. dap_chain_net_srv_price_unit_uid_t a_price_unit, // Unit of service (seconds, megabytes, etc.) Only for SERV_CLASS_PERMANENT - const char a_price_ticker[], + const char a_price_ticker[DAP_CHAIN_TICKER_SIZE_MAX], dap_time_t a_expires, // TS when the service expires const uint8_t *a_ext, uint32_t a_ext_size, diff --git a/modules/service/xchange/dap_chain_net_srv_xchange.c b/modules/service/xchange/dap_chain_net_srv_xchange.c index 83315833c2f6abe33fb4969dd3704f7c29587c67..85884094c4dd2e6967084d7a63b669fec848430b 100644 --- a/modules/service/xchange/dap_chain_net_srv_xchange.c +++ b/modules/service/xchange/dap_chain_net_srv_xchange.c @@ -637,7 +637,6 @@ static dap_chain_datum_tx_t *s_xchange_tx_create_exchange(dap_chain_net_srv_xcha l_seller_addr, NULL, 0); if (!l_tx_out) { dap_chain_datum_tx_delete(l_tx); - DAP_DELETE(l_seller_addr); log_it(L_WARNING, "Can't add selling coins back conditioned output (cond cashback)"); return NULL; }