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 )
|
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);
|
auto stats = son.statistics(*this);
|
||||||
// TODO : We need to add a function that returns if we can deregister SON
|
// 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 >();
|
const auto& son_idx = get_index_type<son_index>().indices().get< by_id >();
|
||||||
auto son = son_idx.find( son_id );
|
auto son = son_idx.find( son_id );
|
||||||
FC_ASSERT( son != son_idx.end() );
|
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)));
|
(head_block_time() - son->statistics(*this).last_down_timestamp >= fc::hours(SON_DEREGISTER_TIME)));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -400,10 +400,13 @@ void database::update_active_sons()
|
||||||
|
|
||||||
const auto& all_sons = get_index_type<son_index>().indices();
|
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 )
|
for( const son_object& son : all_sons )
|
||||||
{
|
{
|
||||||
modify( son, [&]( son_object& obj ){
|
modify( son, [local_vote_buffer_ref]( son_object& obj ){
|
||||||
obj.total_votes = _vote_tally_buffer[son.vote_id];
|
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,
|
inactive,
|
||||||
active,
|
active,
|
||||||
|
request_maintenance,
|
||||||
in_maintenance,
|
in_maintenance,
|
||||||
deregistered
|
deregistered
|
||||||
};
|
};
|
||||||
|
|
@ -94,7 +95,7 @@ namespace graphene { namespace chain {
|
||||||
using son_stats_index = generic_index<son_statistics_object, son_stats_multi_index_type>;
|
using son_stats_index = generic_index<son_statistics_object, son_stats_multi_index_type>;
|
||||||
} } // graphene::chain
|
} } // 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),
|
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) )
|
(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 itr = idx.find(op.son_id);
|
||||||
auto stats = itr->statistics( db() );
|
auto stats = itr->statistics( db() );
|
||||||
// Inactive SONs need not send heartbeats
|
// 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
|
// Account for network delays
|
||||||
fc::time_point_sec min_ts = db().head_block_time() - fc::seconds(5 * db().block_interval());
|
fc::time_point_sec min_ts = db().head_block_time() - fc::seconds(5 * db().block_interval());
|
||||||
// Account for server ntp sync difference
|
// 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;
|
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 )
|
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();
|
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) {
|
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);
|
auto itr = idx.find(op.son_id);
|
||||||
FC_ASSERT( itr != idx.end() );
|
FC_ASSERT( itr != idx.end() );
|
||||||
// Inactive SONs can't go to maintenance
|
// 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();
|
return void_result();
|
||||||
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
} 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) {
|
if(itr->status == son_status::active) {
|
||||||
db().modify(*itr, [](son_object &so) {
|
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)
|
(delete_son)
|
||||||
(list_sons)
|
(list_sons)
|
||||||
(list_active_sons)
|
(list_active_sons)
|
||||||
|
(start_son_maintenance)
|
||||||
|
(stop_son_maintenance)
|
||||||
(add_sidechain_address)
|
(add_sidechain_address)
|
||||||
(update_sidechain_address)
|
(update_sidechain_address)
|
||||||
(delete_sidechain_address)
|
(delete_sidechain_address)
|
||||||
|
|
|
||||||
|
|
@ -699,6 +699,13 @@ BOOST_AUTO_TEST_CASE( maintenance_test )
|
||||||
con.wallet_api_ptr->start_son_maintenance(name, true);
|
con.wallet_api_ptr->start_son_maintenance(name, true);
|
||||||
BOOST_CHECK(generate_block());
|
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
|
// check SON is in maintenance
|
||||||
son_obj = con.wallet_api_ptr->get_son(name);
|
son_obj = con.wallet_api_ptr->get_son(name);
|
||||||
BOOST_CHECK(son_obj.status == son_status::in_maintenance);
|
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);
|
PUSH_TX( db, trx, ~0);
|
||||||
generate_block();
|
generate_block();
|
||||||
trx.clear();
|
trx.clear();
|
||||||
BOOST_CHECK( obj->status == son_status::in_maintenance);
|
BOOST_CHECK( obj->status == son_status::request_maintenance);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t downtime = 0;
|
uint64_t downtime = 0;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue