From 5062d2730a50c90691e158932ea093dd6548a070 Mon Sep 17 00:00:00 2001 From: "roman.khlopkov" <roman.khlopkov@demlabs.net> Date: Thu, 22 Aug 2024 14:45:46 +0300 Subject: [PATCH] [*] First chain TX hash finding correction --- modules/net/dap_chain_ledger.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/modules/net/dap_chain_ledger.c b/modules/net/dap_chain_ledger.c index 0d9e031e58..ab3ce0ed37 100644 --- a/modules/net/dap_chain_ledger.c +++ b/modules/net/dap_chain_ledger.c @@ -3135,18 +3135,15 @@ dap_hash_fast_t dap_ledger_get_first_chain_tx_hash(dap_ledger_t *a_ledger, dap_c return l_hash; } dap_chain_datum_tx_t *l_prev_tx = a_tx; - dap_chain_tx_in_cond_t *l_in_cond = NULL; - dap_chain_tx_out_cond_t *l_out_cond = NULL; - - size_t l_size = 0; - while (( l_in_cond = (dap_chain_tx_in_cond_t*)dap_chain_datum_tx_item_get(l_prev_tx, NULL, (byte_t*)l_out_cond + l_size, TX_ITEM_TYPE_IN_COND, NULL) )) { - l_hash_tmp = l_in_cond->header.tx_prev_hash; + byte_t *l_iter = a_tx->tx_items; + while (( l_iter = dap_chain_datum_tx_item_get(l_prev_tx, NULL, l_iter, TX_ITEM_TYPE_IN_COND, NULL) )) { + l_hash_tmp = ((dap_chain_tx_in_cond_t *)l_iter)->header.tx_prev_hash; if ( dap_hash_fast_is_blank(&l_hash_tmp) ) return l_hash_tmp; - l_size = 0; - if (( l_prev_tx = dap_ledger_tx_find_by_hash(a_ledger, &l_hash_tmp) ) && ( l_out_cond = dap_chain_datum_tx_out_cond_get(l_prev_tx, a_cond_out->header.subtype, NULL) )) { - l_size = dap_chain_datum_item_tx_get_size((const byte_t*)l_out_cond, (byte_t*)l_out_cond - l_prev_tx->tx_items); + if (( l_prev_tx = dap_ledger_tx_find_by_hash(a_ledger, &l_hash_tmp) ) && + ( dap_chain_datum_tx_out_cond_get(l_prev_tx, a_cond_out->header.subtype, NULL) )) { l_hash = l_hash_tmp; + l_iter = l_prev_tx->tx_items; } } return l_hash; -- GitLab