From 452b03a8fec7017695445fd2fcc67821d5ab39ea Mon Sep 17 00:00:00 2001 From: Aleksey Feoktistov <aleksey@synestproject.com> Date: Tue, 11 Jan 2022 08:26:08 +0500 Subject: [PATCH] [*] fix --- modules/consensus/dag-poa/dap_chain_cs_dag_poa.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) 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 4331391841..467594e3d8 100644 --- a/modules/consensus/dag-poa/dap_chain_cs_dag_poa.c +++ b/modules/consensus/dag-poa/dap_chain_cs_dag_poa.c @@ -243,18 +243,19 @@ static int s_cli_dag_poa(int argc, char ** argv, char **a_str_reply) ret = 0; // dap_chain_net_sync_gdb(l_chain_net); // Propagate changes in pool - if (l_event_is_ready) { + if (l_event_is_ready) { // minimum signs & verify passed dap_chain_cs_dag_poa_callback_timer_arg_t * l_callback_arg = DAP_NEW_Z(dap_chain_cs_dag_poa_callback_timer_arg_t); l_callback_arg->dag = l_dag; l_callback_arg->l_event_hash_hex_str = dap_strdup(l_event_new_hash_hex_str); memcpy(&l_callback_arg->event_round_cfg, &l_event_round_cfg, sizeof(dap_chain_cs_dag_event_round_cfg_t)); uint32_t l_timeout = l_event_round_cfg.confirmations_timeout; - // if ( l_timeout <= ((uint64_t)time(NULL) - l_event_round_cfg.ts_confirmations_minimum_completed) ) { + if ( l_event_new->header.signs_count >= l_poa_pvt->auth_certs_count) { - s_callback_round_event_to_chain(l_callback_arg); + s_callback_round_event_to_chain(l_callback_arg); // placement in chain now if max signs } - else { + else if ( l_timeout > ((uint64_t)time(NULL) - l_event_round_cfg.ts_confirmations_minimum_completed) ) { l_timeout = l_timeout - ((uint64_t)time(NULL) - l_event_round_cfg.ts_confirmations_minimum_completed); + // placement in chain by timer if (dap_timerfd_start(l_timeout*1000, (dap_timerfd_callback_t)s_callback_round_event_to_chain, l_callback_arg) == NULL) { @@ -262,6 +263,8 @@ static int s_cli_dag_poa(int argc, char ** argv, char **a_str_reply) } else { log_it(L_NOTICE,"Run timer %dsec. for Event %s", l_timeout, l_event_new_hash_hex_str); } + } else { // placement in chain now if timer out + s_callback_round_event_to_chain(l_callback_arg); } } @@ -294,10 +297,11 @@ static int s_cli_dag_poa(int argc, char ** argv, char **a_str_reply) l_event_hash_str); ret=-1; } + DAP_DELETE(l_event_new); } // DAP_DELETE( l_gdb_group_events ); // DAP_DELETE(l_event_round_cfg); - DAP_DELETE(l_event); + // DAP_DELETE(l_event); } else { dap_chain_node_cli_set_reply_text(a_str_reply, "Command dag_poa requires subcommand 'sign'"); } -- GitLab