BitShares-Core  7.0.2
BitShares blockchain node software and command-line wallet software
is_authorized_asset.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 Cryptonomex, Inc., and contributors.
3  *
4  * The MIT License
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  */
24 #pragma once
25 
26 namespace graphene { namespace chain {
27 
28 class account_object;
29 class asset_object;
30 class database;
31 
32 namespace detail {
33 
34 bool _is_authorized_asset(const database& d, const account_object& acct, const asset_object& asset_obj);
35 
36 }
37 
43 inline bool is_authorized_asset(const database& d, const account_object& acct, const asset_object& asset_obj)
44 {
45  bool fast_check = ( ( 0 == (asset_obj.options.flags & white_list) ) && !(acct.allowed_assets.valid()) );
46 
47  if( fast_check )
48  return true;
49 
50  bool slow_check = detail::_is_authorized_asset( d, acct, asset_obj );
51  return slow_check;
52 }
53 
54 } }
graphene::chain::database
tracks the blockchain state in an extensible manner
Definition: database.hpp:70
graphene::chain::asset_object
tracks the parameters of an asset
Definition: asset_object.hpp:75
graphene::protocol::white_list
@ white_list
accounts must be whitelisted in order to hold or transact this asset
Definition: types.hpp:195
fc::optional::valid
bool valid() const
Definition: optional.hpp:186
graphene::chain::account_object
This class represents an account on the object graph.
Definition: account_object.hpp:180
graphene::chain::is_authorized_asset
bool is_authorized_asset(const database &d, const account_object &acct, const asset_object &asset_obj)
Definition: is_authorized_asset.hpp:43
graphene::chain::detail::_is_authorized_asset
bool _is_authorized_asset(const database &d, const account_object &acct, const asset_object &asset_obj)
Definition: is_authorized_asset.cpp:35
graphene::protocol::asset_options::flags
uint16_t flags
The currently active flags on this permission. See asset_issuer_permission_flags.
Definition: asset_ops.hpp:63
graphene::chain::account_object::allowed_assets
optional< flat_set< asset_id_type > > allowed_assets
Definition: account_object.hpp:283
graphene::chain::asset_object::options
asset_options options
Definition: asset_object.hpp:137
graphene
Definition: api.cpp:48