Skip to content
Snippets Groups Projects
Commit b0ebfe1d authored by Dmitry Gerasimov's avatar Dmitry Gerasimov
Browse files

Merge branch 'develop' of https://gitlab.demlabs.net/cellframe/cellframe-sdk into develop

parents d9a2d43f ea88ad9c
No related branches found
No related tags found
1 merge request!897hotfix-6925
Pipeline #17147 passed with stage
in 1 second
...@@ -472,7 +472,7 @@ int dap_chain_ledger_token_add(dap_ledger_t *a_ledger, dap_chain_datum_token_t * ...@@ -472,7 +472,7 @@ int dap_chain_ledger_token_add(dap_ledger_t *a_ledger, dap_chain_datum_token_t *
l_token_item->auth_signs_total = l_token->signs_total; l_token_item->auth_signs_total = l_token->signs_total;
l_token_item->auth_signs_valid = l_token->signs_valid; l_token_item->auth_signs_valid = l_token->signs_valid;
pthread_rwlock_wrlock(&PVT(a_ledger)->tokens_rwlock); pthread_rwlock_wrlock(&PVT(a_ledger)->tokens_rwlock);
HASH_ADD_STR(PVT(a_ledger)->tokens, ticker, l_token_item); HASH_ADD_STR(PVT(a_ledger)->tokens, ticker, l_token_item);
pthread_rwlock_unlock(&PVT(a_ledger)->tokens_rwlock); pthread_rwlock_unlock(&PVT(a_ledger)->tokens_rwlock);
...@@ -1005,7 +1005,7 @@ dap_string_t *dap_chain_ledger_threshold_info(dap_ledger_t *a_ledger) ...@@ -1005,7 +1005,7 @@ dap_string_t *dap_chain_ledger_threshold_info(dap_ledger_t *a_ledger)
dap_string_t *l_str_ret = dap_string_new(""); dap_string_t *l_str_ret = dap_string_new("");
uint32_t l_counter = 0; uint32_t l_counter = 0;
pthread_rwlock_rdlock(&l_ledger_pvt->threshold_txs_rwlock); pthread_rwlock_rdlock(&l_ledger_pvt->threshold_txs_rwlock);
HASH_ITER(hh, l_ledger_pvt->threshold_txs, l_tx_item, l_tx_tmp){ HASH_ITER(hh, l_ledger_pvt->threshold_txs, l_tx_item, l_tx_tmp){
char l_tx_prev_hash_str[70]={0}; char l_tx_prev_hash_str[70]={0};
char l_time[1024] = {0}; char l_time[1024] = {0};
char l_item_size[70] = {0}; char l_item_size[70] = {0};
...@@ -1017,7 +1017,7 @@ dap_string_t *dap_chain_ledger_threshold_info(dap_ledger_t *a_ledger) ...@@ -1017,7 +1017,7 @@ dap_string_t *dap_chain_ledger_threshold_info(dap_ledger_t *a_ledger)
dap_string_append(l_str_ret, ", time_created:"); dap_string_append(l_str_ret, ", time_created:");
dap_string_append(l_str_ret, l_time); dap_string_append(l_str_ret, l_time);
dap_string_append(l_str_ret, ""); dap_string_append(l_str_ret, "");
sprintf(l_item_size, ", tx_item_size: %d\n", l_tx_item->tx->header.tx_items_size); sprintf(l_item_size, ", tx_item_size: %d\n", l_tx_item->tx->header.tx_items_size);
dap_string_append(l_str_ret, l_item_size); dap_string_append(l_str_ret, l_item_size);
l_counter +=1; l_counter +=1;
} }
...@@ -1028,7 +1028,7 @@ dap_string_t *dap_chain_ledger_threshold_info(dap_ledger_t *a_ledger) ...@@ -1028,7 +1028,7 @@ dap_string_t *dap_chain_ledger_threshold_info(dap_ledger_t *a_ledger)
pthread_rwlock_rdlock(&l_ledger_pvt->threshold_emissions_rwlock); pthread_rwlock_rdlock(&l_ledger_pvt->threshold_emissions_rwlock);
l_counter = 0; l_counter = 0;
dap_chain_ledger_token_emission_item_t *l_emission_item, *l_emission_tmp; dap_chain_ledger_token_emission_item_t *l_emission_item, *l_emission_tmp;
HASH_ITER(hh, l_ledger_pvt->threshold_emissions, l_emission_item, l_emission_tmp){ HASH_ITER(hh, l_ledger_pvt->threshold_emissions, l_emission_item, l_emission_tmp){
char l_emission_hash_str[70]={0}; char l_emission_hash_str[70]={0};
char l_item_size[70] = {0}; char l_item_size[70] = {0};
dap_chain_hash_fast_to_str(&l_emission_item->datum_token_emission_hash,l_emission_hash_str,sizeof(l_emission_hash_str)); dap_chain_hash_fast_to_str(&l_emission_item->datum_token_emission_hash,l_emission_hash_str,sizeof(l_emission_hash_str));
...@@ -1053,7 +1053,7 @@ dap_string_t *dap_chain_ledger_threshold_hash_info(dap_ledger_t *a_ledger, dap_c ...@@ -1053,7 +1053,7 @@ dap_string_t *dap_chain_ledger_threshold_hash_info(dap_ledger_t *a_ledger, dap_c
dap_string_t *l_str_ret = dap_string_new(""); dap_string_t *l_str_ret = dap_string_new("");
uint32_t l_counter = 0; uint32_t l_counter = 0;
pthread_rwlock_rdlock(&l_ledger_pvt->threshold_txs_rwlock); pthread_rwlock_rdlock(&l_ledger_pvt->threshold_txs_rwlock);
HASH_ITER(hh, l_ledger_pvt->threshold_txs, l_tx_item, l_tx_tmp){ HASH_ITER(hh, l_ledger_pvt->threshold_txs, l_tx_item, l_tx_tmp){
if (!memcmp(l_threshold_hash,&l_tx_item->tx_hash_fast, sizeof(dap_chain_hash_fast_t))){ if (!memcmp(l_threshold_hash,&l_tx_item->tx_hash_fast, sizeof(dap_chain_hash_fast_t))){
char l_tx_hash_str[70]={0}; char l_tx_hash_str[70]={0};
dap_chain_hash_fast_to_str(l_threshold_hash,l_tx_hash_str,sizeof(l_tx_hash_str)); dap_chain_hash_fast_to_str(l_threshold_hash,l_tx_hash_str,sizeof(l_tx_hash_str));
...@@ -1068,7 +1068,7 @@ dap_string_t *dap_chain_ledger_threshold_hash_info(dap_ledger_t *a_ledger, dap_c ...@@ -1068,7 +1068,7 @@ dap_string_t *dap_chain_ledger_threshold_hash_info(dap_ledger_t *a_ledger, dap_c
pthread_rwlock_rdlock(&l_ledger_pvt->threshold_emissions_rwlock); pthread_rwlock_rdlock(&l_ledger_pvt->threshold_emissions_rwlock);
l_counter = 0; l_counter = 0;
dap_chain_ledger_token_emission_item_t *l_emission_item, *l_emission_tmp; dap_chain_ledger_token_emission_item_t *l_emission_item, *l_emission_tmp;
HASH_ITER(hh, l_ledger_pvt->threshold_emissions, l_emission_item, l_emission_tmp){ HASH_ITER(hh, l_ledger_pvt->threshold_emissions, l_emission_item, l_emission_tmp){
if (!memcmp(&l_emission_item->datum_token_emission_hash,l_threshold_hash, sizeof(dap_chain_hash_fast_t))){ if (!memcmp(&l_emission_item->datum_token_emission_hash,l_threshold_hash, sizeof(dap_chain_hash_fast_t))){
char l_emission_hash_str[70]={0}; char l_emission_hash_str[70]={0};
dap_chain_hash_fast_to_str(l_threshold_hash,l_emission_hash_str,sizeof(l_emission_hash_str)); dap_chain_hash_fast_to_str(l_threshold_hash,l_emission_hash_str,sizeof(l_emission_hash_str));
...@@ -1091,9 +1091,9 @@ dap_string_t *dap_chain_ledger_balance_info(dap_ledger_t *a_ledger) ...@@ -1091,9 +1091,9 @@ dap_string_t *dap_chain_ledger_balance_info(dap_ledger_t *a_ledger)
pthread_rwlock_rdlock(&l_ledger_pvt->balance_accounts_rwlock); pthread_rwlock_rdlock(&l_ledger_pvt->balance_accounts_rwlock);
uint32_t l_counter = 0; uint32_t l_counter = 0;
dap_ledger_wallet_balance_t *l_balance_item, *l_balance_tmp; dap_ledger_wallet_balance_t *l_balance_item, *l_balance_tmp;
HASH_ITER(hh, l_ledger_pvt->balance_accounts, l_balance_item, l_balance_tmp){ HASH_ITER(hh, l_ledger_pvt->balance_accounts, l_balance_item, l_balance_tmp){
char l_time[1024] = {0}; char l_time[1024] = {0};
//log_it(L_DEBUG,"Ledger balance key %s, token_ticker: %s, balance: %s", l_balance_key, l_balance_item->token_ticker, //log_it(L_DEBUG,"Ledger balance key %s, token_ticker: %s, balance: %s", l_balance_key, l_balance_item->token_ticker,
// dap_chain_balance_print(l_balance_item->balance)); // dap_chain_balance_print(l_balance_item->balance));
dap_string_append(l_str_ret, "Ledger balance key: "); dap_string_append(l_str_ret, "Ledger balance key: ");
dap_string_append(l_str_ret, l_balance_item->key); dap_string_append(l_str_ret, l_balance_item->key);
...@@ -1563,7 +1563,7 @@ int dap_chain_ledger_token_emission_add_check(dap_ledger_t *a_ledger, byte_t *a_ ...@@ -1563,7 +1563,7 @@ int dap_chain_ledger_token_emission_add_check(dap_ledger_t *a_ledger, byte_t *a_
return -4; return -4;
} }
} }
//additional check for private tokens //additional check for private tokens
if ((l_token_item->type == DAP_CHAIN_DATUM_TOKEN_TYPE_PRIVATE_DECL) || if ((l_token_item->type == DAP_CHAIN_DATUM_TOKEN_TYPE_PRIVATE_DECL) ||
(l_token_item->type == DAP_CHAIN_DATUM_TOKEN_TYPE_PRIVATE_UPDATE) || (l_token_item->type == DAP_CHAIN_DATUM_TOKEN_TYPE_PRIVATE_UPDATE) ||
...@@ -1634,7 +1634,7 @@ bool s_chain_ledger_token_address_check(dap_chain_addr_t * l_addrs, dap_chain_da ...@@ -1634,7 +1634,7 @@ bool s_chain_ledger_token_address_check(dap_chain_addr_t * l_addrs, dap_chain_da
return true; return true;
} }
return false; return false;
} }
bool s_chain_ledger_token_tsd_check(dap_chain_ledger_token_item_t * a_token_item, dap_chain_datum_token_emission_t *a_token_emission) bool s_chain_ledger_token_tsd_check(dap_chain_ledger_token_item_t * a_token_item, dap_chain_datum_token_emission_t *a_token_emission)
...@@ -3262,13 +3262,14 @@ int dap_chain_ledger_tx_remove(dap_ledger_t *a_ledger, dap_chain_hash_fast_t *a_ ...@@ -3262,13 +3262,14 @@ int dap_chain_ledger_tx_remove(dap_ledger_t *a_ledger, dap_chain_hash_fast_t *a_
if (!l_item_used) { // Add it to spent items if (!l_item_used) { // Add it to spent items
l_item_used = DAP_NEW_Z(dap_chain_ledger_tx_spent_item_t); l_item_used = DAP_NEW_Z(dap_chain_ledger_tx_spent_item_t);
memcpy(&l_item_used->tx_hash_fast, a_tx_hash, sizeof(dap_chain_hash_fast_t)); memcpy(&l_item_used->tx_hash_fast, a_tx_hash, sizeof(dap_chain_hash_fast_t));
strncpy(l_item_used->token_ticker, l_item_tmp->cache_data.token_ticker, DAP_CHAIN_TICKER_SIZE_MAX); int l_len = strnlen(l_item_tmp->cache_data.token_ticker, DAP_CHAIN_TICKER_SIZE_MAX);
strncpy(l_item_used->token_ticker, l_item_tmp->cache_data.token_ticker, l_len);
HASH_ADD_BYHASHVALUE(hh, l_ledger_priv->spent_items, tx_hash_fast, sizeof(dap_chain_hash_fast_t), l_hash_value, l_item_used); HASH_ADD_BYHASHVALUE(hh, l_ledger_priv->spent_items, tx_hash_fast, sizeof(dap_chain_hash_fast_t), l_hash_value, l_item_used);
// Add it to cache // Add it to cache
l_gdb_group = dap_chain_ledger_get_gdb_group(a_ledger, DAP_CHAIN_LEDGER_SPENT_TXS_STR); l_gdb_group = dap_chain_ledger_get_gdb_group(a_ledger, DAP_CHAIN_LEDGER_SPENT_TXS_STR);
char *l_tx_hash_str = dap_hash_fast_to_str_new(a_tx_hash); char *l_tx_hash_str = dap_hash_fast_to_str_new(a_tx_hash);
if ( dap_global_db_set(l_gdb_group, l_tx_hash_str, l_item_used->token_ticker, -1, false, NULL, NULL)) { if ( dap_global_db_set(l_gdb_group, l_tx_hash_str, l_item_used->token_ticker, l_len, false, NULL, NULL)) {
if(s_debug_more) if(s_debug_more)
log_it(L_WARNING, "Ledger cache mismatch"); log_it(L_WARNING, "Ledger cache mismatch");
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment