Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • cellframe/cellframe-sdk
  • MIKA83/cellframe-sdk
2 results
Show changes
Commits on Source (2)
...@@ -5523,22 +5523,23 @@ dap_list_t *dap_chain_ledger_get_list_tx_outs_with_val(dap_ledger_t *a_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) { switch (l_type) {
case TX_ITEM_TYPE_OUT_OLD: { case TX_ITEM_TYPE_OUT_OLD: {
dap_chain_tx_out_old_t *l_out = (dap_chain_tx_out_old_t *)l_list_tmp->data; 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; continue;
}
l_value = GET_256_FROM_64(l_out->header.value); l_value = GET_256_FROM_64(l_out->header.value);
} break; } break;
case TX_ITEM_TYPE_OUT: { case TX_ITEM_TYPE_OUT: {
dap_chain_tx_out_t *l_out = (dap_chain_tx_out_t *)l_list_tmp->data; 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; continue;
}
l_value = l_out->header.value; l_value = l_out->header.value;
} break; } break;
case TX_ITEM_TYPE_OUT_EXT: { 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; 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)) || if (memcmp(a_addr_from, &l_out_ext->addr, sizeof(dap_chain_addr_t)) ||
strcmp((char *)a_token_ticker, l_out_ext->token)) { strcmp((char *)a_token_ticker, l_out_ext->token) ||
IS_ZERO_256(l_out_ext->header.value) ) {
continue; continue;
} }
l_value = l_out_ext->header.value; 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 ...@@ -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)) { 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); dap_chain_tx_used_out_item_t *l_item = DAP_NEW_Z(dap_chain_tx_used_out_item_t);
if ( !l_item ) { if ( !l_item ) {
log_it(L_CRITICAL, "Out of memory");
if (l_list_used_out) if (l_list_used_out)
dap_list_free_full(l_list_used_out, NULL); dap_list_free_full(l_list_used_out, NULL);
dap_list_free(l_list_out_items); dap_list_free(l_list_out_items);
......
...@@ -106,7 +106,6 @@ DAP_STATIC_INLINE size_t s_get_esbocs_message_size(dap_chain_esbocs_message_t *a ...@@ -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_chain_esbocs_session_t * s_session_items;
static dap_timerfd_t *s_session_cs_timer = NULL;
typedef struct dap_chain_esbocs_pvt { typedef struct dap_chain_esbocs_pvt {
// Base params // Base params
...@@ -483,17 +482,16 @@ static int s_callback_created(dap_chain_t *a_chain, dap_config_t *a_chain_net_cf ...@@ -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); 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); DL_APPEND(s_session_items, l_session);
if (!s_session_cs_timer) { l_session->cs_timer = dap_timerfd_start(1000, s_session_timer, l_session);
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");
debug_if(l_esbocs_pvt->debug, L_MSG, "Consensus main timer is started");
}
DAP_CHAIN_PVT(a_chain)->cs_started = true; DAP_CHAIN_PVT(a_chain)->cs_started = true;
return 0; return 0;
} }
bool dap_chain_esbocs_started() 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) 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) ...@@ -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; dap_chain_esbocs_session_t *l_session = l_esbocs->session;
pthread_mutex_lock(&l_session->mutex); pthread_mutex_lock(&l_session->mutex);
DL_DELETE(s_session_items, l_session); DL_DELETE(s_session_items, l_session);
if (!s_session_items) dap_timerfd_delete_mt(l_session->cs_timer->worker, l_session->cs_timer->esocket_uuid);
dap_timerfd_delete_mt(s_session_cs_timer->worker, s_session_cs_timer->esocket_uuid);
s_session_round_clear(l_session); s_session_round_clear(l_session);
dap_chain_esbocs_sync_item_t *l_sync_item, *l_sync_tmp; 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) { 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) ...@@ -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) static bool s_session_timer(void *a_arg)
{ {
UNUSED(a_arg); dap_chain_esbocs_session_t *l_session = a_arg;
dap_chain_esbocs_session_t *l_session = NULL; s_session_proc_state(l_session);
DL_FOREACH(s_session_items, l_session) {
s_session_proc_state(l_session);
}
return true; return true;
} }
......
...@@ -153,6 +153,7 @@ typedef struct dap_chain_esbocs_penalty_item { ...@@ -153,6 +153,7 @@ typedef struct dap_chain_esbocs_penalty_item {
typedef struct dap_chain_esbocs_session { typedef struct dap_chain_esbocs_session {
pthread_mutex_t mutex; pthread_mutex_t mutex;
dap_timerfd_t *cs_timer;
dap_chain_block_t *processing_candidate; dap_chain_block_t *processing_candidate;
dap_chain_t *chain; dap_chain_t *chain;
......
...@@ -1245,19 +1245,16 @@ void chain_mempool_proc(struct dap_http_simple *cl_st, void * arg) ...@@ -1245,19 +1245,16 @@ void chain_mempool_proc(struct dap_http_simple *cl_st, void * arg)
DAP_DEL_Z(a_key); DAP_DEL_Z(a_key);
} else } else
*return_code = Http_Status_BadRequest; *return_code = Http_Status_BadRequest;
} } else
else *return_code = Http_Status_BadRequest; *return_code = Http_Status_BadRequest;
enc_http_delegate_delete(l_enc_delegate); enc_http_delegate_delete(l_enc_delegate);
} } else
else *return_code = Http_Status_Unauthorized; *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 // 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);
}
}
} }
/** /**
......
...@@ -2767,12 +2767,11 @@ int s_net_init(const char * a_net_name, uint16_t a_acl_idx) ...@@ -2767,12 +2767,11 @@ int s_net_init(const char * a_net_name, uint16_t a_acl_idx)
if(l_cfg_new) { if(l_cfg_new) {
list_priority *l_chain_prior = DAP_NEW_Z(list_priority); list_priority *l_chain_prior = DAP_NEW_Z(list_priority);
if (!l_chain_prior) { if (!l_chain_prior) {
log_it(L_CRITICAL, "Memory allocation error"); log_it(L_CRITICAL, "Memory allocation error");
DAP_DELETE (l_entry_name); DAP_DELETE(l_entry_name);
closedir(l_chains_dir); closedir(l_chains_dir);
dap_config_close(l_cfg_new); dap_config_close(l_cfg_new);
dap_config_close(l_cfg); dap_config_close(l_cfg);
closedir(l_chains_dir);
return -1; return -1;
} }
l_chain_prior->prior = dap_config_get_item_uint16_default(l_cfg_new, "chain", "load_priority", 100); 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) ...@@ -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) 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; return false;
for(uint16_t i = 0; i < PVT(a_net)->gdb_sync_nodes_addrs_count; i++) { 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) { if(a_node_addr.uint64 == PVT(a_net)->gdb_sync_nodes_addrs[i].uint64) {
......
...@@ -129,7 +129,7 @@ char *dap_chain_net_srv_order_create(dap_chain_net_t * a_net, ...@@ -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 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. 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 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 dap_time_t a_expires, // TS when the service expires
const uint8_t *a_ext, const uint8_t *a_ext,
uint32_t a_ext_size, uint32_t a_ext_size,
......
...@@ -637,7 +637,6 @@ static dap_chain_datum_tx_t *s_xchange_tx_create_exchange(dap_chain_net_srv_xcha ...@@ -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); l_seller_addr, NULL, 0);
if (!l_tx_out) { if (!l_tx_out) {
dap_chain_datum_tx_delete(l_tx); 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)"); log_it(L_WARNING, "Can't add selling coins back conditioned output (cond cashback)");
return NULL; return NULL;
} }
......