From 130b54116cce52fc718f5490e9d328e80ee00302 Mon Sep 17 00:00:00 2001 From: theoreticalbts Date: Thu, 11 Feb 2016 02:38:18 -0500 Subject: [PATCH] Inline fast path of is_authorized_asset() #566 --- .../graphene/chain/is_authorized_asset.hpp | 17 ++++++++++++++++- libraries/chain/is_authorized_asset.cpp | 8 ++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/libraries/chain/include/graphene/chain/is_authorized_asset.hpp b/libraries/chain/include/graphene/chain/is_authorized_asset.hpp index 1c7569c0..5062136e 100644 --- a/libraries/chain/include/graphene/chain/is_authorized_asset.hpp +++ b/libraries/chain/include/graphene/chain/is_authorized_asset.hpp @@ -29,11 +29,26 @@ class account_object; class asset_object; 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 * 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; +} } } diff --git a/libraries/chain/is_authorized_asset.cpp b/libraries/chain/is_authorized_asset.cpp index 0dda6ece..585b1da6 100644 --- a/libraries/chain/is_authorized_asset.cpp +++ b/libraries/chain/is_authorized_asset.cpp @@ -30,7 +30,9 @@ namespace graphene { namespace chain { -bool is_authorized_asset( +namespace detail { + +bool _is_authorized_asset( const database& d, const account_object& acct, const asset_object& asset_obj) @@ -62,4 +64,6 @@ bool is_authorized_asset( return false; } -} } +} // detail + +} } // graphene::chain