diff --git a/dap-sdk b/dap-sdk index 67ce27ac8f32206811d9185832fc2ec605f9d7e1..5410384db398c73f6667cf4aae3683790cf12126 160000 --- a/dap-sdk +++ b/dap-sdk @@ -1 +1 @@ -Subproject commit 67ce27ac8f32206811d9185832fc2ec605f9d7e1 +Subproject commit 5410384db398c73f6667cf4aae3683790cf12126 diff --git a/modules/chain/dap_chain.c b/modules/chain/dap_chain.c index 106f2ec150429f167cca65295dc2ca55f63b4f3f..decae85247d873dca50cc80f55a698f5100d62cd 100644 --- a/modules/chain/dap_chain.c +++ b/modules/chain/dap_chain.c @@ -342,13 +342,12 @@ static bool s_datum_in_chain_types(uint16_t datum_type, dap_chain_type_t *chain_ /** * @brief dap_chain_load_from_cfg * Loading chain from config file - * @param a_ledger - ledger object * @param a_chain_net_name - chain name, taken from config, for example - "home21-network" * @param a_chain_net_id - dap_chain_net_id_t chain network identification * @param a_chain_cfg_name chain config name, for example "network/home21-network/chain-0" * @return dap_chain_t* */ -dap_chain_t * dap_chain_load_from_cfg(dap_ledger_t* a_ledger, const char * a_chain_net_name,dap_chain_net_id_t a_chain_net_id, const char * a_chain_cfg_name) +dap_chain_t *dap_chain_load_from_cfg(const char *a_chain_net_name, dap_chain_net_id_t a_chain_net_id, const char *a_chain_cfg_name) { log_it (L_DEBUG, "Loading chain from config \"%s\"", a_chain_cfg_name); diff --git a/modules/chain/include/dap_chain.h b/modules/chain/include/dap_chain.h index d868605fef63dbb827de8ba0cf4e4058b5d798a7..08cd3ab3bc0b0dca131845cebc0c3452c14b5ad0 100644 --- a/modules/chain/include/dap_chain.h +++ b/modules/chain/include/dap_chain.h @@ -253,7 +253,7 @@ bool dap_chain_has_file_store(dap_chain_t * a_chain); void dap_chain_info_dump_log(dap_chain_t * a_chain); dap_chain_t * dap_chain_find_by_id(dap_chain_net_id_t a_chain_net_id,dap_chain_id_t a_chain_id); -dap_chain_t * dap_chain_load_from_cfg(dap_ledger_t* a_ledger,const char * a_chain_net_name, dap_chain_net_id_t a_chain_net_id, const char * a_chain_cfg_name); +dap_chain_t *dap_chain_load_from_cfg(const char *a_chain_net_name, dap_chain_net_id_t a_chain_net_id, const char *a_chain_cfg_name); void dap_chain_delete(dap_chain_t * a_chain); void dap_chain_add_callback_notify(dap_chain_t * a_chain, dap_chain_callback_notify_t a_callback, void * a_arg); diff --git a/modules/consensus/esbocs/dap_chain_cs_esbocs.c b/modules/consensus/esbocs/dap_chain_cs_esbocs.c index 29e2abf30762dc2d425c9ba1117cc9fd63529c65..8f2c94e5f936fde105a5bcce172e22b25bd52a58 100644 --- a/modules/consensus/esbocs/dap_chain_cs_esbocs.c +++ b/modules/consensus/esbocs/dap_chain_cs_esbocs.c @@ -268,13 +268,20 @@ static int s_callback_new(dap_chain_t *a_chain, dap_config_t *a_chain_cfg) l_validator->weight = uint256_1; l_esbocs_pvt->poa_validators = dap_list_append(l_esbocs_pvt->poa_validators, l_validator); + dap_chain_net_t *l_net = dap_chain_net_by_id(a_chain->net_id); if (!l_esbocs_pvt->poa_mode) { // auth certs in PoA mode will be first PoS validators keys dap_hash_fast_t l_stake_tx_hash = {}; - dap_chain_net_t *l_net = dap_chain_net_by_id(a_chain->net_id); uint256_t l_weight = dap_chain_net_srv_stake_get_allowed_min_value(); dap_chain_net_srv_stake_key_delegate(l_net, &l_signing_addr, &l_stake_tx_hash, l_weight, &l_signer_node_addr); } + // Preset reward for block signs, before first reward decree + const char *l_preset_reward_str = dap_config_get_item_str(a_chain_cfg, "esbocs", "preset_reward"); + if (l_preset_reward_str) { + uint256_t l_preset_reward = dap_chain_balance_scan(l_preset_reward_str); + if (!IS_ZERO_256(l_preset_reward)) + dap_chain_net_add_reward(l_net, l_preset_reward, 0); + } } l_blocks->chain->callback_created = s_callback_created; diff --git a/modules/net/dap_chain_net.c b/modules/net/dap_chain_net.c index 4574f24bb453d70352ed06d550db2394771f7c6a..d0959a256e5ef5fc13c697f296d91589327b8a46 100644 --- a/modules/net/dap_chain_net.c +++ b/modules/net/dap_chain_net.c @@ -2271,8 +2271,7 @@ int s_net_init(const char * a_net_name, uint16_t a_acl_idx) while(l_list){ list_priority *l_chain_prior = l_list->data; // Create chain object - l_chain = dap_chain_load_from_cfg(l_net->pub.ledger, l_net->pub.name, - l_net->pub.id, l_chain_prior->chains_path); + l_chain = dap_chain_load_from_cfg(l_net->pub.name, l_net->pub.id, l_chain_prior->chains_path); if(l_chain) DL_APPEND(l_net->pub.chains, l_chain); else @@ -2313,6 +2312,9 @@ int s_net_init(const char * a_net_name, uint16_t a_acl_idx) default: l_ledger_flags |= DAP_LEDGER_CHECK_CELLS_DS | DAP_LEDGER_CHECK_TOKEN_EMISSION; } + // init LEDGER model + l_net->pub.ledger = dap_ledger_create(l_net, l_ledger_flags); + for (dap_chain_t *l_chain = l_net->pub.chains; l_chain; l_chain = l_chain->next) { if (!l_chain->callback_get_poa_certs) continue; @@ -2322,9 +2324,11 @@ int s_net_init(const char * a_net_name, uint16_t a_acl_idx) } if (!l_net->pub.keys) log_it(L_WARNING, "PoA certificates for net %s not found", l_net->pub.name); - // init LEDGER model - l_net->pub.ledger = dap_ledger_create(l_net, l_ledger_flags); + // Decrees initializing + dap_chain_net_decree_init(l_net); + + dap_config_close(l_cfg); return 0; } @@ -2352,9 +2356,6 @@ int s_net_load(dap_chain_net_t *a_net) } else dap_chain_net_srv_stake_load_cache(l_net); - //load decree - dap_chain_net_decree_init(l_net); - // load chains dap_chain_t *l_chain = l_net->pub.chains; while (l_chain) { diff --git a/modules/net/dap_chain_net_decree.c b/modules/net/dap_chain_net_decree.c index 35c26ed668abf7e16e932ff4c254e35a1d3fea0a..0d795bd7ae476522fe48ae5dc2329bdb6883dc52 100644 --- a/modules/net/dap_chain_net_decree.c +++ b/modules/net/dap_chain_net_decree.c @@ -95,9 +95,6 @@ int dap_chain_net_decree_init(dap_chain_net_t *a_net) a_net->pub.decree = l_decree; - // Preset reward for block signs, before first reward decree - dap_chain_net_add_reward(a_net, dap_chain_balance_scan("2851988815387151461"), 0); - return 0; }