added extra code to track a reverse index on whitelist/blacklist

This commit is contained in:
Daniel Larimer 2015-09-28 15:42:38 -04:00
parent 246459af3f
commit b65763fdb6
2 changed files with 31 additions and 0 deletions

View file

@ -180,12 +180,26 @@ void_result account_whitelist_evaluator::do_apply(const account_whitelist_operat
a.whitelisting_accounts.insert(o.authorizing_account);
else
a.whitelisting_accounts.erase(o.authorizing_account);
if( o.new_listing & o.black_listed )
a.blacklisting_accounts.insert(o.authorizing_account);
else
a.blacklisting_accounts.erase(o.authorizing_account);
});
/** for tracking purposes only, this state is not needed to evaluate */
d.modify( o.authorizing_account(d), [&]( account_object& a ) {
if( o.new_listing & o.white_listed )
a.whitelisted_accounts.insert( o.account_to_list );
else
a.whitelisted_accounts.erase( o.account_to_list );
if( o.new_listing & o.black_listed )
a.blacklisted_accounts.insert( o.account_to_list );
else
a.blacklisted_accounts.erase( o.account_to_list );
});
return void_result();
} FC_CAPTURE_AND_RETHROW( (o) ) }

View file

@ -170,6 +170,21 @@ namespace graphene { namespace chain {
*/
flat_set<account_id_type> whitelisting_accounts;
/**
* Optionally track all of the accounts this account has whitelisted or blacklisted, these should
* be made Immutable so that when the account object is cloned no deep copy is required. This state is
* tracked for GUI display purposes.
*
* TODO: move white list tracking to its own multi-index container rather than having 4 fields on an
* account. This will scale better because under the current design if you whitelist 2000 accounts,
* then every time someone fetches this account object they will get the full list of 2000 accounts.
*/
///@{
set<account_id_type> whitelisted_accounts;
set<account_id_type> blacklisted_accounts;
///@}
/**
* This is a set of all accounts which have 'blacklisted' this account. Blacklisting is only used in core
* validation for the purpose of forbidding accounts from holding and transacting in whitelisted assets. This
@ -264,6 +279,7 @@ namespace graphene { namespace chain {
set<address> before_address_members;
};
/**
* @brief This secondary index will allow a reverse lookup of all accounts that have been referred by
* a particular account.
@ -330,6 +346,7 @@ FC_REFLECT_DERIVED( graphene::chain::account_object,
(membership_expiration_date)(registrar)(referrer)(lifetime_referrer)
(network_fee_percentage)(lifetime_referrer_fee_percentage)(referrer_rewards_percentage)
(name)(owner)(active)(options)(statistics)(whitelisting_accounts)(blacklisting_accounts)
(whitelisting_accounts)(blacklisted_accounts)
(cashback_vb) )
FC_REFLECT_DERIVED( graphene::chain::account_balance_object,