BitShares-Core  6.1.0
BitShares blockchain implementation and command-line interface software
is_authorized_asset.cpp
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 
27 
29 #include <graphene/chain/hardfork.hpp>
30 
31 namespace graphene { namespace chain {
32 
33 namespace detail {
34 
36  const database& d,
37  const account_object& acct,
38  const asset_object& asset_obj)
39 {
40  // committee-account is always allowed to transact after BSIP 86
41  if( HARDFORK_BSIP_86_PASSED( d.head_block_time() ) )
42  {
43  static const object_id_type committee_account_id( GRAPHENE_COMMITTEE_ACCOUNT );
44  if( acct.id == committee_account_id )
45  return true;
46  }
47 
48  if( acct.allowed_assets.valid() )
49  {
50  if( acct.allowed_assets->find( asset_obj.get_id() ) == acct.allowed_assets->end() )
51  return false;
52  // must still pass other checks even if it is in allowed_assets
53  }
54 
55  for( const auto& id : acct.blacklisting_accounts )
56  {
57  if( asset_obj.options.blacklist_authorities.find(id) != asset_obj.options.blacklist_authorities.end() )
58  return false;
59  }
60 
61  if( asset_obj.options.whitelist_authorities.size() == 0 )
62  return true;
63 
64  for( const auto& id : acct.whitelisting_accounts )
65  {
66  if( asset_obj.options.whitelist_authorities.find(id) != asset_obj.options.whitelist_authorities.end() )
67  return true;
68  }
69 
70  return false;
71 }
72 
73 } // detail
74 
75 } } // graphene::chain
flat_set< account_id_type > blacklisting_accounts
flat_set< account_id_type > blacklist_authorities
Definition: asset_ops.hpp:81
time_point_sec head_block_time() const
Definition: db_getter.cpp:67
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
object_id< SpaceID, TypeID > get_id() const
Definition: object.hpp:113
object_id_type id
Definition: object.hpp:69
bool valid() const
Definition: optional.hpp:186
#define GRAPHENE_COMMITTEE_ACCOUNT
Definition: config.hpp:140
flat_set< account_id_type > whitelisting_accounts
tracks the parameters of an assetAll assets have a globally unique symbol name that controls how they...
bool _is_authorized_asset(const database &d, const account_object &acct, const asset_object &asset_obj)
flat_set< account_id_type > whitelist_authorities
Definition: asset_ops.hpp:76