Inline fast path of is_authorized_asset() #566

This commit is contained in:
theoreticalbts 2016-02-11 02:38:18 -05:00
parent 68a0ffa1aa
commit 130b54116c
2 changed files with 22 additions and 3 deletions

View file

@ -29,11 +29,26 @@ class account_object;
class asset_object; class asset_object;
class database; class database;
namespace detail {
bool _is_authorized_asset(const database& d, const account_object& acct, const asset_object& asset_obj);
}
/** /**
* @return true if the account is whitelisted and not blacklisted to transact in the provided asset; false * @return true if the account is whitelisted and not blacklisted to transact in the provided asset; false
* otherwise. * otherwise.
*/ */
bool is_authorized_asset(const database& d, const account_object& acct, const asset_object& asset_obj); inline bool is_authorized_asset(const database& d, const account_object& acct, const asset_object& asset_obj)
{
bool fast_check = !(asset_obj.options.flags & white_list);
if( fast_check )
return true;
bool slow_check = detail::_is_authorized_asset( d, acct, asset_obj );
return slow_check;
}
} } } }

View file

@ -30,7 +30,9 @@
namespace graphene { namespace chain { namespace graphene { namespace chain {
bool is_authorized_asset( namespace detail {
bool _is_authorized_asset(
const database& d, const database& d,
const account_object& acct, const account_object& acct,
const asset_object& asset_obj) const asset_object& asset_obj)
@ -62,4 +64,6 @@ bool is_authorized_asset(
return false; return false;
} }
} } } // detail
} } // graphene::chain