Compare commits
3 commits
master
...
feature/SO
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
28c7d3b5e3 | ||
|
|
49011894bd | ||
|
|
5db4de044b |
7 changed files with 25 additions and 11 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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -400,10 +400,13 @@ void database::update_active_sons()
|
|||
|
||||
const auto& all_sons = get_index_type<son_index>().indices();
|
||||
|
||||
auto& local_vote_buffer_ref = _vote_tally_buffer;
|
||||
for( const son_object& son : all_sons )
|
||||
{
|
||||
modify( son, [&]( son_object& obj ){
|
||||
obj.total_votes = _vote_tally_buffer[son.vote_id];
|
||||
modify( son, [local_vote_buffer_ref]( son_object& obj ){
|
||||
obj.total_votes = local_vote_buffer_ref[obj.vote_id];
|
||||
if(obj.status == son_status::request_maintenance)
|
||||
obj.status = son_status::in_maintenance;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2221,6 +2221,8 @@ FC_API( graphene::wallet::wallet_api,
|
|||
(delete_son)
|
||||
(list_sons)
|
||||
(list_active_sons)
|
||||
(start_son_maintenance)
|
||||
(stop_son_maintenance)
|
||||
(add_sidechain_address)
|
||||
(update_sidechain_address)
|
||||
(delete_sidechain_address)
|
||||
|
|
|
|||
|
|
@ -699,6 +699,13 @@ BOOST_AUTO_TEST_CASE( maintenance_test )
|
|||
con.wallet_api_ptr->start_son_maintenance(name, true);
|
||||
BOOST_CHECK(generate_block());
|
||||
|
||||
// check SON is in maintenance
|
||||
son_obj = con.wallet_api_ptr->get_son(name);
|
||||
BOOST_CHECK(son_obj.status == son_status::request_maintenance);
|
||||
|
||||
// process maintenance
|
||||
BOOST_CHECK(generate_maintenance_block());
|
||||
|
||||
// check SON is in maintenance
|
||||
son_obj = con.wallet_api_ptr->get_son(name);
|
||||
BOOST_CHECK(son_obj.status == son_status::in_maintenance);
|
||||
|
|
|
|||
|
|
@ -732,7 +732,7 @@ BOOST_AUTO_TEST_CASE( son_heartbeat_test ) {
|
|||
PUSH_TX( db, trx, ~0);
|
||||
generate_block();
|
||||
trx.clear();
|
||||
BOOST_CHECK( obj->status == son_status::in_maintenance);
|
||||
BOOST_CHECK( obj->status == son_status::request_maintenance);
|
||||
}
|
||||
|
||||
uint64_t downtime = 0;
|
||||
|
|
|
|||
Loading…
Reference in a new issue