#310 - check txs_signed contains active_sidechain_type

This commit is contained in:
Vlad Dobromyslov 2022-04-12 11:02:31 +03:00
parent b7ac7830ab
commit 0f442ef9f6

View file

@ -220,14 +220,14 @@ void database::pay_sons()
else {
son_weight += get_weight_before_son2_hf(_vote_tally_buffer[son_obj->sidechain_vote_ids.at(active_sidechain_type)]);
}
const uint64_t txs_signed = s.txs_signed.at(active_sidechain_type);
const uint64_t txs_signed = s.txs_signed.contains(active_sidechain_type) ? s.txs_signed.at(active_sidechain_type) : 0;
weighted_total_txs_signed += (txs_signed * son_weight);
});
// Now pay off each SON proportional to the number of transactions signed.
get_index_type<son_stats_index>().inspect_all_objects([this, &weighted_total_txs_signed, &dpo, &son_budget, &get_weight, &get_weight_before_son2_hf, &now, &active_sidechain_type](const object& o) {
const son_statistics_object& s = static_cast<const son_statistics_object&>(o);
const uint64_t txs_signed = s.txs_signed.at(active_sidechain_type);
const uint64_t txs_signed = s.txs_signed.contains(active_sidechain_type) ? s.txs_signed.at(active_sidechain_type) : 0;
if(txs_signed > 0){
const auto& idx = get_index_type<son_index>().indices().get<by_id>();
@ -252,7 +252,8 @@ void database::pay_sons()
//Reset the tx counter in each son statistics object
modify( s, [&]( son_statistics_object& _s)
{
_s.txs_signed.at(active_sidechain_type) = 0;
if(_s.txs_signed.contains(active_sidechain_type))
_s.txs_signed.at(active_sidechain_type) = 0;
});
}
});