From afbf43b2e8137872bd9002a9ad4d3b1052f94f0e Mon Sep 17 00:00:00 2001 From: "alexey.stratulat" <alexey.stratulat@demlabs.net> Date: Mon, 23 Jan 2023 11:15:34 +0000 Subject: [PATCH] Backport 5927 --- modules/mempool/dap_chain_mempool.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/modules/mempool/dap_chain_mempool.c b/modules/mempool/dap_chain_mempool.c index ee44cac4de..904435d085 100644 --- a/modules/mempool/dap_chain_mempool.c +++ b/modules/mempool/dap_chain_mempool.c @@ -313,6 +313,7 @@ int dap_chain_mempool_tx_create_massive( dap_chain_t * a_chain, dap_enc_key_t *a return -2; } + dap_chain_hash_fast_t l_tx_new_hash = {0}; for (size_t i=0; i< a_tx_num ; i++){ log_it(L_DEBUG, "Prepare tx %zu",i); // find the transactions from which to take away coins @@ -404,13 +405,12 @@ int dap_chain_mempool_tx_create_massive( dap_chain_t * a_chain, dap_enc_key_t *a // now tx is formed - calc size and hash size_t l_tx_size = dap_chain_datum_tx_get_size(l_tx_new); - dap_chain_hash_fast_t l_tx_new_hash; dap_hash_fast(l_tx_new, l_tx_size, &l_tx_new_hash); // If we have value back - update balance cache if (!IS_ZERO_256(l_value_back)) { //log_it(L_DEBUG,"We have value back %"DAP_UINT64_FORMAT_U" now lets see how many outputs we have", l_value_back); int l_item_count = 0; - dap_list_t *l_list_out_items = dap_chain_datum_tx_items_get( l_tx_new, TX_ITEM_TYPE_OUT, + dap_list_t *l_list_out_items = dap_chain_datum_tx_items_get( l_tx_new, TX_ITEM_TYPE_OUT_ALL, &l_item_count); dap_list_t *l_list_tmp = l_list_out_items; int l_out_idx_tmp = 0; // current index of 'out' item @@ -422,6 +422,11 @@ int dap_chain_mempool_tx_create_massive( dap_chain_t * a_chain, dap_enc_key_t *a l_out_idx_tmp++; continue; } + if (l_out->header.type == TX_ITEM_TYPE_OUT_COND) { + l_list_tmp = l_list_tmp->next; + l_out_idx_tmp++; + continue; + } if ( memcmp(&l_out->addr, a_addr_from, sizeof (*a_addr_from))==0 ){ list_used_item_t *l_item_back = DAP_NEW_Z(list_used_item_t); l_item_back->tx_hash_fast = l_tx_new_hash; @@ -448,7 +453,7 @@ int dap_chain_mempool_tx_create_massive( dap_chain_t * a_chain, dap_enc_key_t *a l_objs[i].key = dap_chain_hash_fast_to_str_new(&l_tx_new_hash); //continue; l_objs[i].value = (uint8_t *)l_datum; - l_objs[i].value_len = l_tx_size + sizeof(l_datum->header); + l_objs[i].value_len = dap_chain_datum_size(l_datum); log_it(L_DEBUG, "Prepared obj with key %s (value_len = %"DAP_UINT64_FORMAT_U")", l_objs[i].key? l_objs[i].key :"NULL" , l_objs[i].value_len ); -- GitLab