Compare commits
5 commits
master
...
bug/513-nu
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1a5cab9965 | ||
|
|
3f558da2a1 | ||
|
|
5e7acde885 | ||
|
|
188d55158c | ||
|
|
6145c3c89b |
4 changed files with 39 additions and 15 deletions
|
|
@ -191,11 +191,6 @@ object_id_type account_create_evaluator::do_apply( const account_create_operatio
|
|||
obj.active = o.active;
|
||||
obj.options = o.options;
|
||||
|
||||
if (!obj.options.extensions.value.num_son.valid())
|
||||
{
|
||||
obj.options.extensions.value = account_options::ext();
|
||||
}
|
||||
|
||||
obj.statistics = d.create<account_statistics_object>([&obj](account_statistics_object& s){
|
||||
s.owner = obj.id;
|
||||
s.name = obj.name;
|
||||
|
|
@ -335,6 +330,7 @@ void_result account_update_evaluator::do_apply( const account_update_operation&
|
|||
a.top_n_control_flags = 0;
|
||||
}
|
||||
if( o.new_options ) a.options = *o.new_options;
|
||||
|
||||
if( o.extensions.value.owner_special_authority.valid() )
|
||||
{
|
||||
a.owner_special_authority = *(o.extensions.value.owner_special_authority);
|
||||
|
|
|
|||
|
|
@ -2382,7 +2382,24 @@ void database::perform_chain_maintenance(const signed_block& next_block, const g
|
|||
|
||||
if ( opinion_account.options.extensions.value.num_son.valid() )
|
||||
{
|
||||
for(const auto& num_sidechain_son : *opinion_account.options.extensions.value.num_son) {
|
||||
auto active_sidechains = active_sidechain_types(d.head_block_time());
|
||||
auto num_son_map = *opinion_account.options.extensions.value.num_son;
|
||||
|
||||
if ( num_son_map.size() != active_sidechains.size())
|
||||
{
|
||||
for (const auto& num_sidechain_son : num_son_map)
|
||||
{
|
||||
FC_ASSERT(active_sidechains.find(num_sidechain_son.first) != active_sidechains.end());
|
||||
active_sidechains.erase(num_sidechain_son.first);
|
||||
}
|
||||
|
||||
for (auto missing_num_son : active_sidechains)
|
||||
{
|
||||
num_son_map[missing_num_son] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
for(const auto& num_sidechain_son : num_son_map) {
|
||||
const auto sidechain = num_sidechain_son.first;
|
||||
const auto& num_son = num_sidechain_son.second;
|
||||
if (num_son <= props.parameters.maximum_son_count()) {
|
||||
|
|
|
|||
|
|
@ -36,21 +36,16 @@ namespace graphene { namespace chain {
|
|||
bool is_cheap_name( const string& n );
|
||||
|
||||
/// These are the fields which can be updated by the active authority.
|
||||
struct account_options
|
||||
struct account_options
|
||||
{
|
||||
struct ext
|
||||
{
|
||||
/// The number of active son members this account votes the blockchain should appoint
|
||||
/// Must not exceed the actual number of son members voted for in @ref votes
|
||||
optional< flat_map<sidechain_type, uint16_t> > num_son = []{
|
||||
flat_map<sidechain_type, uint16_t> num_son;
|
||||
for(const auto& active_sidechain_type : all_sidechain_types){
|
||||
num_son[active_sidechain_type] = 0;
|
||||
}
|
||||
return num_son;
|
||||
}();
|
||||
optional< flat_map<sidechain_type, uint16_t> > num_son;
|
||||
};
|
||||
|
||||
|
||||
/// The memo key is the key this account will typically use to encrypt/sign transaction memos and other non-
|
||||
/// validated account activities. This field is here to prevent confusion if the active authority has zero or
|
||||
/// multiple keys in it.
|
||||
|
|
|
|||
|
|
@ -2838,8 +2838,24 @@ public:
|
|||
if (!votes_removed)
|
||||
FC_THROW("Account ${account} is already not voting for SON ${son}", ("account", voting_account)("son", son));
|
||||
}
|
||||
auto active_sidechains = active_sidechain_types(time_point::now());
|
||||
auto num_son_map = *voting_account_object.options.extensions.value.num_son;
|
||||
|
||||
if ( num_son_map.size() != active_sidechains.size())
|
||||
{
|
||||
for (const auto& num_sidechain_son : num_son_map)
|
||||
{
|
||||
FC_ASSERT(active_sidechains.find(num_sidechain_son.first) != active_sidechains.end());
|
||||
active_sidechains.erase(num_sidechain_son.first);
|
||||
}
|
||||
|
||||
for (auto missing_num_son : active_sidechains)
|
||||
{
|
||||
num_son_map[missing_num_son] = 0;
|
||||
}
|
||||
}
|
||||
FC_ASSERT( voting_account_object.options.extensions.value.num_son.valid() , "Invalid son number" );
|
||||
(*voting_account_object.options.extensions.value.num_son)[sidechain] = desired_number_of_sons;
|
||||
num_son_map[sidechain] = desired_number_of_sons;
|
||||
|
||||
account_update_operation account_update_op;
|
||||
account_update_op.account = voting_account_object.id;
|
||||
|
|
|
|||
Loading…
Reference in a new issue