diff --git a/dap-sdk b/dap-sdk index e66e1b75e024988a9391dc0ba58694af1813c796..71af5db6a71def94c73ca8b2d260b50621f1cd7b 160000 --- a/dap-sdk +++ b/dap-sdk @@ -1 +1 @@ -Subproject commit e66e1b75e024988a9391dc0ba58694af1813c796 +Subproject commit 71af5db6a71def94c73ca8b2d260b50621f1cd7b diff --git a/modules/chain/dap_chain_ledger.c b/modules/chain/dap_chain_ledger.c index 5aebcb7e7917097302b741ae6fef7433a6e595af..e709bed752ee255b01cf10be365fc48b030479ae 100644 --- a/modules/chain/dap_chain_ledger.c +++ b/modules/chain/dap_chain_ledger.c @@ -2296,7 +2296,7 @@ static void s_load_cache_gdb_loaded_spent_txs_callback(dap_global_db_context_t * } char * l_gdb_group = dap_chain_ledger_get_gdb_group(l_ledger, DAP_CHAIN_LEDGER_BALANCES_STR); - dap_global_db_get_all(l_gdb_group,0, s_load_cache_gdb_loaded_balances_callback, l_ledger); + dap_global_db_get_all(l_gdb_group, 0, s_load_cache_gdb_loaded_balances_callback, l_ledger); DAP_DELETE(l_gdb_group); } @@ -2339,7 +2339,7 @@ static void s_load_cache_gdb_loaded_txs_callback(dap_global_db_context_t *a_glob } char *l_gdb_group = dap_chain_ledger_get_gdb_group(l_ledger, DAP_CHAIN_LEDGER_SPENT_TXS_STR); - dap_global_db_get_all(l_gdb_group,0, s_load_cache_gdb_loaded_spent_txs_callback, l_ledger); + dap_global_db_get_all(l_gdb_group, 0, s_load_cache_gdb_loaded_spent_txs_callback, l_ledger); DAP_DELETE(l_gdb_group); } @@ -2365,7 +2365,7 @@ static void s_load_cache_gdb_loaded_stake_lock_callback(dap_global_db_context_t } char* l_gdb_group = dap_chain_ledger_get_gdb_group(l_ledger, DAP_CHAIN_LEDGER_TXS_STR); - dap_global_db_get_all(l_gdb_group,0, s_load_cache_gdb_loaded_txs_callback, l_ledger); + dap_global_db_get_all(l_gdb_group, 0, s_load_cache_gdb_loaded_txs_callback, l_ledger); DAP_DELETE(l_gdb_group); } @@ -2417,7 +2417,7 @@ static void s_load_cache_gdb_loaded_emissions_callback(dap_global_db_context_t * } char* l_gdb_group = dap_chain_ledger_get_gdb_group(l_ledger, DAP_CHAIN_LEDGER_STAKE_LOCK_STR); - dap_global_db_get_all(l_gdb_group,0, s_load_cache_gdb_loaded_stake_lock_callback, l_ledger); + dap_global_db_get_all(l_gdb_group, 0, s_load_cache_gdb_loaded_stake_lock_callback, l_ledger); DAP_DELETE(l_gdb_group); } @@ -2469,7 +2469,7 @@ static void s_load_cache_gdb_loaded_tokens_callback(dap_global_db_context_t *a_g } char *l_gdb_group = dap_chain_ledger_get_gdb_group(l_ledger, DAP_CHAIN_LEDGER_EMISSIONS_STR); - dap_global_db_get_all(l_gdb_group,0, s_load_cache_gdb_loaded_emissions_callback, l_ledger); + dap_global_db_get_all(l_gdb_group, 0, s_load_cache_gdb_loaded_emissions_callback, l_ledger); DAP_DELETE(l_gdb_group); } @@ -2483,7 +2483,7 @@ void dap_chain_ledger_load_cache(dap_ledger_t *a_ledger) char *l_gdb_group = dap_chain_ledger_get_gdb_group(a_ledger, DAP_CHAIN_LEDGER_TOKENS_STR); pthread_mutex_lock(& l_ledger_pvt->load_mutex); - dap_global_db_get_all(l_gdb_group,0,s_load_cache_gdb_loaded_tokens_callback, a_ledger); + dap_global_db_get_all(l_gdb_group, 0, s_load_cache_gdb_loaded_tokens_callback, a_ledger); while (!l_ledger_pvt->load_end) pthread_cond_wait(& l_ledger_pvt->load_cond, &l_ledger_pvt->load_mutex); pthread_mutex_unlock(& l_ledger_pvt->load_mutex); diff --git a/modules/consensus/dag-poa/dap_chain_cs_dag_poa.c b/modules/consensus/dag-poa/dap_chain_cs_dag_poa.c index c3e41ba0eb4bcf572f3e2a3d66c41cba0d8d799f..5e38c68e3cf309ddd3a260c854e42da15a569974 100644 --- a/modules/consensus/dag-poa/dap_chain_cs_dag_poa.c +++ b/modules/consensus/dag-poa/dap_chain_cs_dag_poa.c @@ -466,7 +466,7 @@ static void s_poa_round_check_callback_round_clean(dap_global_db_context_t *a_gl static void s_poa_round_clean(void *a_arg) { dap_chain_cs_dag_t *l_dag = DAP_CHAIN_CS_DAG((dap_chain_t *)a_arg); - dap_global_db_get_all(l_dag->gdb_group_events_round_new,0,s_poa_round_check_callback_round_clean, l_dag); + dap_global_db_get_all(l_dag->gdb_group_events_round_new, 0, s_poa_round_check_callback_round_clean, l_dag); } static bool s_round_event_ready_minimum_check(dap_chain_cs_dag_t *a_dag, dap_chain_cs_dag_event_t *a_event, @@ -646,9 +646,8 @@ static void s_callback_round_event_to_chain_callback_get_round_item(dap_global_d */ static bool s_callback_round_event_to_chain(struct round_timer_arg *a_callback_arg) { - dap_chain_cs_dag_t * l_dag = a_callback_arg->dag; - char * l_gdb_group_events = l_dag->gdb_group_events_round_new; - dap_global_db_get_all_raw(l_gdb_group_events, 0, 0, s_callback_round_event_to_chain_callback_get_round_item, a_callback_arg); + dap_chain_cs_dag_t *l_dag = a_callback_arg->dag; + dap_global_db_get_all_raw(l_dag->gdb_group_events_round_new, 0, 0, s_callback_round_event_to_chain_callback_get_round_item, a_callback_arg); return false; } diff --git a/modules/consensus/esbocs/dap_chain_cs_esbocs.c b/modules/consensus/esbocs/dap_chain_cs_esbocs.c index c05c113b49a6f77d195586beaf78a79c8f35172f..9f3836d26db7c9912fc308b9f1ff44182ad5dfe8 100644 --- a/modules/consensus/esbocs/dap_chain_cs_esbocs.c +++ b/modules/consensus/esbocs/dap_chain_cs_esbocs.c @@ -307,7 +307,9 @@ static void s_session_db_serialize(dap_global_db_context_t *a_context, void *a_a uint64_t l_limit_time = l_time_store_lim_hours ? dap_nanotime_now() - dap_nanotime_from_sec(l_time_store_lim_hours * 3600) : 0; size_t l_objs_count = 0; dap_global_db_pkt_t *l_pkt = 0; - dap_store_obj_t *l_objs = dap_global_db_get_all_raw_unsafe(a_context, l_sync_group, 0, &l_objs_count); + dap_db_iter_t *l_iter = dap_global_db_driver_iter_create(l_sync_group); + dap_store_obj_t *l_objs = dap_global_db_get_all_raw_unsafe(a_context, l_iter, &l_objs_count); + dap_global_db_driver_iter_delete(l_iter); for (size_t i = 0; i < l_objs_count; i++) { dap_store_obj_t *it = l_objs + i; if (l_notify_item->ttl && it->timestamp < l_limit_time) { @@ -337,7 +339,10 @@ static void s_session_db_serialize(dap_global_db_context_t *a_context, void *a_a char *l_del_sync_group = dap_strdup_printf("%s.del", l_sync_group); l_objs_count = 0; - l_objs = dap_global_db_get_all_raw_unsafe(a_context, l_del_sync_group, 0, &l_objs_count); + l_iter = dap_global_db_driver_iter_create(l_sync_group); + l_objs = dap_global_db_get_all_raw_unsafe(a_context, l_iter, &l_objs_count); + dap_global_db_driver_iter_delete(l_iter); + DAP_DELETE(l_del_sync_group); for (size_t i = 0; i < l_objs_count; i++) { dap_store_obj_t *it = l_objs + i; @@ -1650,7 +1655,7 @@ static void s_session_round_finish(dap_chain_esbocs_session_t *a_session, dap_ch tmp->fee_need_cfg = PVT(a_session->esbocs)->fee_coll_set; tmp->key_from = PVT(a_session->esbocs)->blocks_sign_key; - dap_global_db_get_all(s_block_fee_group,0,s_check_db_callback_fee_collect,tmp); + dap_global_db_get_all(s_block_fee_group, 0, s_check_db_callback_fee_collect,tmp); } } diff --git a/modules/mempool/dap_chain_mempool.c b/modules/mempool/dap_chain_mempool.c index 574e66c30174ffd2912b4d072a45de19085b7c4d..cfb038b4e6d9e2dc68dc32d14f9803aa8555fe8c 100644 --- a/modules/mempool/dap_chain_mempool.c +++ b/modules/mempool/dap_chain_mempool.c @@ -70,7 +70,7 @@ #define LOG_TAG "dap_chain_mempool" -static void s_tx_create_massive_gdb_save_callback(dap_global_db_context_t *a_global_db_context, +static bool s_tx_create_massive_gdb_save_callback(dap_global_db_context_t *a_global_db_context, int a_rc, const char *a_group, const size_t a_values_total, const size_t a_values_count, dap_global_db_obj_t *a_values, void *a_arg); @@ -599,15 +599,17 @@ int dap_chain_mempool_tx_create_massive( dap_chain_t * a_chain, dap_enc_key_t *a * @param a_values * @param a_arg */ -static void s_tx_create_massive_gdb_save_callback(dap_global_db_context_t *a_global_db_context, +static bool s_tx_create_massive_gdb_save_callback(dap_global_db_context_t *a_global_db_context, int a_rc, const char *a_group, const size_t a_values_total, const size_t a_values_count, dap_global_db_obj_t *a_values, void *a_arg) { - if( a_rc ==0 ) { + if(!a_rc) { log_it(L_NOTICE, "%zu transaction are placed in mempool", a_values_total); - }else{ + return true; + } else { log_it(L_ERROR, "Can't place %zu transactions in mempool", a_values_total); + return false; } } diff --git a/modules/net/dap_chain_node_cli_cmd.c b/modules/net/dap_chain_node_cli_cmd.c index 92e91b76c8642a5e67b29036d9b3706ac96d57c5..7df02749e7f0915a1307173daffaf23ae1fd534a 100644 --- a/modules/net/dap_chain_node_cli_cmd.c +++ b/modules/net/dap_chain_node_cli_cmd.c @@ -6308,7 +6308,9 @@ int cmd_gdb_export(int a_argc, char **a_argv, char **a_str_reply) for (dap_list_t *l_list = l_groups_list; l_list; l_list = dap_list_next(l_list)) { size_t l_store_obj_count = 0; char *l_group_name = (char *)l_list->data; - pdap_store_obj_t l_store_obj = dap_global_db_get_all_raw_sync(l_group_name,0, &l_store_obj_count); + + dap_store_obj_t *l_store_obj = dap_global_db_get_all_raw_sync(l_group_name, &l_store_obj_count); + if (!l_store_obj_count) { log_it(L_INFO, "Group %s is empty or not found", l_group_name); continue; @@ -6402,7 +6404,7 @@ int cmd_gdb_import(int a_argc, char **a_argv, char ** a_str_reply) log_it(L_INFO, "Group %zu: %s", i, l_group_name); struct json_object *l_json_records = json_object_object_get(l_group_obj, "records"); size_t l_records_count = json_object_array_length(l_json_records); - pdap_store_obj_t l_group_store = DAP_NEW_Z_SIZE(dap_store_obj_t, l_records_count * sizeof(dap_store_obj_t)); + dap_store_obj_t *l_group_store = DAP_NEW_Z_SIZE(dap_store_obj_t, l_records_count * sizeof(dap_store_obj_t)); for (size_t j = 0; j < l_records_count; ++j) { struct json_object *l_record, *l_id, *l_key, *l_value, *l_value_len, *l_ts; l_record = json_object_array_get_idx(l_json_records, j); diff --git a/modules/service/stake/dap_chain_net_srv_stake_pos_delegate.c b/modules/service/stake/dap_chain_net_srv_stake_pos_delegate.c index 8c883b33a5cd230e8f5b329ce9c321c7f9f48412..925a07087cac28ff068ff30965df6525b35ff763 100644 --- a/modules/service/stake/dap_chain_net_srv_stake_pos_delegate.c +++ b/modules/service/stake/dap_chain_net_srv_stake_pos_delegate.c @@ -365,7 +365,9 @@ int dap_chain_net_srv_stake_load_cache(dap_chain_net_t *a_net) return 0; char *l_gdb_group = dap_chain_ledger_get_gdb_group(l_ledger, DAP_CHAIN_NET_SRV_STAKE_POS_DELEGATE_GDB_GROUP); size_t l_objs_count = 0; - dap_store_obj_t *l_store_obj = dap_global_db_get_all_raw_sync(l_gdb_group, 0, &l_objs_count); + + dap_store_obj_t *l_store_obj = dap_global_db_get_all_raw_sync(l_gdb_group, &l_objs_count); + if (!l_objs_count || !l_store_obj) { log_it(L_ATT, "Stake cache data not found"); return -1; diff --git a/modules/type/dag/dap_chain_cs_dag.c b/modules/type/dag/dap_chain_cs_dag.c index 9ba85421521b410a8b8a67dfc9de8f360b2eed79..774e164ec00232db237616e9676742845c8e6282 100644 --- a/modules/type/dag/dap_chain_cs_dag.c +++ b/modules/type/dag/dap_chain_cs_dag.c @@ -327,7 +327,10 @@ int dap_chain_cs_dag_new(dap_chain_t * a_chain, dap_config_t * a_chain_cfg) l_dag->round_current = l_current_round ? *(uint64_t*)l_current_round : 0; DAP_DELETE(l_current_round); debug_if(s_debug_more, L_INFO, "Current round id %"DAP_UINT64_FORMAT_U, l_dag->round_current); + dap_global_db_get_all_raw(l_dag->gdb_group_events_round_new, 0, 0, s_dag_rounds_events_iter, l_dag); + + PVT(l_dag)->mempool_timer = dap_interval_timer_create(15000, s_timer_process_callback, a_chain); PVT(l_dag)->events_treshold = NULL; PVT(l_dag)->events_treshold_conflicted = NULL;