add request_maintenance SON state
This commit is contained in:
parent
e0e427a366
commit
5db4de044b
3 changed files with 10 additions and 8 deletions
|
|
@ -164,7 +164,8 @@ std::set<son_id_type> database::get_sons_to_be_deregistered()
|
|||
|
||||
for( auto& son : son_idx )
|
||||
{
|
||||
if(son.status == son_status::in_maintenance)
|
||||
if((son.status == son_status::in_maintenance) ||
|
||||
(son.status == son_status::request_maintenance))
|
||||
{
|
||||
auto stats = son.statistics(*this);
|
||||
// TODO : We need to add a function that returns if we can deregister SON
|
||||
|
|
@ -251,7 +252,7 @@ bool database::is_son_dereg_valid( const son_id_type& son_id )
|
|||
const auto& son_idx = get_index_type<son_index>().indices().get< by_id >();
|
||||
auto son = son_idx.find( son_id );
|
||||
FC_ASSERT( son != son_idx.end() );
|
||||
bool ret = ( son->status == son_status::in_maintenance &&
|
||||
bool ret = ( ((son->status == son_status::in_maintenance) || (son->status == son_status::request_maintenance)) &&
|
||||
(head_block_time() - son->statistics(*this).last_down_timestamp >= fc::hours(SON_DEREGISTER_TIME)));
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ namespace graphene { namespace chain {
|
|||
{
|
||||
inactive,
|
||||
active,
|
||||
request_maintenance,
|
||||
in_maintenance,
|
||||
deregistered
|
||||
};
|
||||
|
|
@ -94,7 +95,7 @@ namespace graphene { namespace chain {
|
|||
using son_stats_index = generic_index<son_statistics_object, son_stats_multi_index_type>;
|
||||
} } // graphene::chain
|
||||
|
||||
FC_REFLECT_ENUM(graphene::chain::son_status, (inactive)(active)(in_maintenance)(deregistered) )
|
||||
FC_REFLECT_ENUM(graphene::chain::son_status, (inactive)(active)(request_maintenance)(in_maintenance)(deregistered) )
|
||||
|
||||
FC_REFLECT_DERIVED( graphene::chain::son_object, (graphene::db::object),
|
||||
(son_account)(vote_id)(total_votes)(url)(deposit)(signing_key)(pay_vb)(status)(sidechain_public_keys) )
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ void_result son_heartbeat_evaluator::do_evaluate(const son_heartbeat_operation&
|
|||
auto itr = idx.find(op.son_id);
|
||||
auto stats = itr->statistics( db() );
|
||||
// Inactive SONs need not send heartbeats
|
||||
FC_ASSERT(itr->status == son_status::active || itr->status == son_status::in_maintenance, "Inactive SONs need not send heartbeats");
|
||||
FC_ASSERT(itr->status == son_status::active || itr->status == son_status::in_maintenance || itr->status == son_status::request_maintenance, "Inactive SONs need not send heartbeats");
|
||||
// Account for network delays
|
||||
fc::time_point_sec min_ts = db().head_block_time() - fc::seconds(5 * db().block_interval());
|
||||
// Account for server ntp sync difference
|
||||
|
|
@ -139,7 +139,7 @@ object_id_type son_heartbeat_evaluator::do_apply(const son_heartbeat_operation&
|
|||
is_son_active = false;
|
||||
}
|
||||
|
||||
if(itr->status == son_status::in_maintenance) {
|
||||
if((itr->status == son_status::in_maintenance) || (itr->status == son_status::request_maintenance)) {
|
||||
db().modify( itr->statistics( db() ), [&]( son_statistics_object& sso )
|
||||
{
|
||||
sso.current_interval_downtime += op.ts.sec_since_epoch() - sso.last_down_timestamp.sec_since_epoch();
|
||||
|
|
@ -188,7 +188,7 @@ object_id_type son_report_down_evaluator::do_apply(const son_report_down_operati
|
|||
});
|
||||
|
||||
db().modify(*itr, [&op](son_object &so) {
|
||||
so.status = son_status::in_maintenance;
|
||||
so.status = son_status::request_maintenance;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -203,7 +203,7 @@ void_result son_maintenance_evaluator::do_evaluate(const son_maintenance_operati
|
|||
auto itr = idx.find(op.son_id);
|
||||
FC_ASSERT( itr != idx.end() );
|
||||
// Inactive SONs can't go to maintenance
|
||||
FC_ASSERT(itr->status == son_status::active || itr->status == son_status::in_maintenance, "Inactive SONs can't go to maintenance");
|
||||
FC_ASSERT(itr->status == son_status::active || itr->status == son_status::in_maintenance || itr->status == son_status::request_maintenance, "Inactive SONs can't go to maintenance");
|
||||
return void_result();
|
||||
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
||||
|
||||
|
|
@ -215,7 +215,7 @@ object_id_type son_maintenance_evaluator::do_apply(const son_maintenance_operati
|
|||
{
|
||||
if(itr->status == son_status::active) {
|
||||
db().modify(*itr, [](son_object &so) {
|
||||
so.status = son_status::in_maintenance;
|
||||
so.status = son_status::request_maintenance;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue