BitShares-Core  6.1.0
BitShares blockchain implementation and command-line interface 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 } }
bool is_authorized_asset(const database &d, const account_object &acct, const asset_object &asset_obj)
This class represents an account on the object graphAccounts are the primary unit of authority on the...
tracks the blockchain state in an extensible manner
Definition: database.hpp:70
Definition: api.cpp:48
optional< flat_set< asset_id_type > > allowed_assets
bool valid() const
Definition: optional.hpp:186
accounts must be whitelisted in order to hold or transact this asset
Definition: types.hpp:195
tracks the parameters of an assetAll assets have a globally unique symbol name that controls how they...
uint16_t flags
The currently active flags on this permission. See asset_issuer_permission_flags. ...
Definition: asset_ops.hpp:63
bool _is_authorized_asset(const database &d, const account_object &acct, const asset_object &asset_obj)