From b65763fdb670bcf1f7cd4918cf899b25fd8f3822 Mon Sep 17 00:00:00 2001 From: Daniel Larimer Date: Mon, 28 Sep 2015 15:42:38 -0400 Subject: [PATCH] added extra code to track a reverse index on whitelist/blacklist --- libraries/chain/account_evaluator.cpp | 14 ++++++++++++++ .../include/graphene/chain/account_object.hpp | 17 +++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/libraries/chain/account_evaluator.cpp b/libraries/chain/account_evaluator.cpp index a7714376..9b7f6fbd 100644 --- a/libraries/chain/account_evaluator.cpp +++ b/libraries/chain/account_evaluator.cpp @@ -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) ) } diff --git a/libraries/chain/include/graphene/chain/account_object.hpp b/libraries/chain/include/graphene/chain/account_object.hpp index 675f11b8..9d7088a0 100644 --- a/libraries/chain/include/graphene/chain/account_object.hpp +++ b/libraries/chain/include/graphene/chain/account_object.hpp @@ -170,6 +170,21 @@ namespace graphene { namespace chain { */ flat_set 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 whitelisted_accounts; + set 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
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,