keep maintenance state during active SON set changes
This commit is contained in:
parent
3e2295bea0
commit
d0ac2272a0
1 changed files with 46 additions and 8 deletions
|
|
@ -471,17 +471,55 @@ void database::update_active_sons()
|
|||
} else {
|
||||
ilog( "Active SONs set CHANGED" );
|
||||
// Store new SON info, initiate wallet recreation and transfer of funds
|
||||
for( const son_object& son : cur_active_sons )
|
||||
vector<son_info> sons_to_remove;
|
||||
// find all cur_active_sons members that is not in new_active_sons
|
||||
for_each(cur_active_sons.begin(), cur_active_sons.end(),
|
||||
[&sons_to_remove, &new_active_sons](const son_info& si)
|
||||
{
|
||||
if(std::find(new_active_sons.begin(), new_active_sons.end(), si) ==
|
||||
new_active_sons.end())
|
||||
{
|
||||
sons_to_remove.push_back(si);
|
||||
}
|
||||
}
|
||||
);
|
||||
const auto& idx = get_index_type<son_index>().indices().get<by_id>();
|
||||
for( const son_info& si : sons_to_remove )
|
||||
{
|
||||
modify( son, [&]( son_object& obj ){
|
||||
obj.status = son_status::inactive;
|
||||
});
|
||||
auto son = idx.find( si.son_id );
|
||||
if(son == idx.end()) // SON is deleted already
|
||||
continue;
|
||||
// keep maintenance status for nodes becoming inactive
|
||||
if(son->status == son_status::active)
|
||||
{
|
||||
modify( *son, [&]( son_object& obj ){
|
||||
obj.status = son_status::inactive;
|
||||
});
|
||||
}
|
||||
}
|
||||
for( const son_object& son : new_active_sons )
|
||||
vector<son_info> sons_to_add;
|
||||
// find all new_active_sons members that is not in cur_active_sons
|
||||
for_each(new_active_sons.begin(), new_active_sons.end(),
|
||||
[&sons_to_add, &cur_active_sons](const son_info& si)
|
||||
{
|
||||
if(std::find(cur_active_sons.begin(), cur_active_sons.end(), si) ==
|
||||
cur_active_sons.end())
|
||||
{
|
||||
sons_to_add.push_back(si);
|
||||
}
|
||||
}
|
||||
);
|
||||
for( const son_info& si : sons_to_add )
|
||||
{
|
||||
modify( son, [&]( son_object& obj ){
|
||||
obj.status = son_status::active;
|
||||
});
|
||||
auto son = idx.find( si.son_id );
|
||||
FC_ASSERT(son != idx.end(), "Invalid SON in active list, id={sonid}.", ("sonid", si.son_id));
|
||||
// keep maintenance status for new nodes
|
||||
if(son->status == son_status::inactive)
|
||||
{
|
||||
modify( *son, [&]( son_object& obj ){
|
||||
obj.status = son_status::active;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue