SON233 - Provide correct downtime metrics to user (#278)
This commit is contained in:
parent
b952522b01
commit
6e61d6b055
4 changed files with 21 additions and 1 deletions
|
|
@ -165,6 +165,20 @@ void database::pay_sons()
|
|||
}
|
||||
}
|
||||
|
||||
void database::update_son_metrics()
|
||||
{
|
||||
const auto& son_idx = get_index_type<son_index>().indices().get< by_id >();
|
||||
for( auto& son : son_idx )
|
||||
{
|
||||
auto& stats = son.statistics(*this);
|
||||
modify( stats, [&]( son_statistics_object& _stats)
|
||||
{
|
||||
_stats.total_downtime += _stats.current_interval_downtime;
|
||||
_stats.current_interval_downtime = 0;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void database::pay_workers( share_type& budget )
|
||||
{
|
||||
// ilog("Processing payroll! Available budget is ${b}", ("b", budget));
|
||||
|
|
@ -542,6 +556,8 @@ void database::update_active_sons()
|
|||
_sso.scheduler.update(active_sons);
|
||||
});
|
||||
|
||||
update_son_metrics();
|
||||
|
||||
if(gpo.active_sons.size() > 0 ) {
|
||||
if(gpo.parameters.get_son_btc_account_id() == GRAPHENE_NULL_ACCOUNT) {
|
||||
const auto& son_btc_account = create<account_object>( [&]( account_object& obj ) {
|
||||
|
|
|
|||
|
|
@ -548,6 +548,7 @@ namespace graphene { namespace chain {
|
|||
void perform_chain_maintenance(const signed_block& next_block, const global_property_object& global_props);
|
||||
void update_active_witnesses();
|
||||
void update_active_committee_members();
|
||||
void update_son_metrics();
|
||||
void update_active_sons();
|
||||
void update_worker_votes();
|
||||
|
||||
|
|
|
|||
|
|
@ -165,6 +165,7 @@ object_id_type son_heartbeat_evaluator::do_apply(const son_heartbeat_operation&
|
|||
|
||||
void_result son_report_down_evaluator::do_evaluate(const son_report_down_operation& op)
|
||||
{ try {
|
||||
FC_ASSERT(db().head_block_time() >= HARDFORK_SON_TIME, "Not allowed until SON HARDFORK"); // can be removed after HF date pass
|
||||
FC_ASSERT(op.payer == db().get_global_properties().parameters.get_son_btc_account_id(), "Payer should be the son btc account");
|
||||
const auto& idx = db().get_index_type<son_index>().indices().get<by_id>();
|
||||
FC_ASSERT( idx.find(op.son_id) != idx.end() );
|
||||
|
|
|
|||
|
|
@ -247,6 +247,7 @@ void peerplays_sidechain_plugin_impl::create_son_down_proposals()
|
|||
|
||||
chain::database& d = plugin.database();
|
||||
const chain::global_property_object& gpo = d.get_global_properties();
|
||||
const chain::dynamic_global_property_object& dgpo = d.get_dynamic_global_properties();
|
||||
const auto& idx = d.get_index_type<chain::son_index>().indices().get<by_id>();
|
||||
std::set<son_id_type> sons_being_reported_down = d.get_sons_being_reported_down();
|
||||
chain::son_id_type my_son_id = *(_sons.begin());
|
||||
|
|
@ -256,7 +257,8 @@ void peerplays_sidechain_plugin_impl::create_son_down_proposals()
|
|||
}
|
||||
auto son_obj = idx.find( son_inf.son_id );
|
||||
auto stats = son_obj->statistics(d);
|
||||
fc::time_point_sec last_active_ts = stats.last_active_timestamp;
|
||||
fc::time_point_sec last_maintenance_time = dgpo.next_maintenance_time - gpo.parameters.maintenance_interval;
|
||||
fc::time_point_sec last_active_ts = ((stats.last_active_timestamp > last_maintenance_time) ? stats.last_active_timestamp : last_maintenance_time);
|
||||
int64_t down_threshold = 2*180000000;
|
||||
if(son_obj->status == chain::son_status::active && (fc::time_point::now() - last_active_ts) > fc::microseconds(down_threshold)) {
|
||||
ilog("peerplays_sidechain_plugin: sending son down proposal for ${t} from ${s}",("t",std::string(object_id_type(son_obj->id)))("s",std::string(object_id_type(my_son_id))));
|
||||
|
|
|
|||
Loading…
Reference in a new issue