BitShares-Core  7.0.2
BitShares blockchain node software and command-line wallet 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
graphene::db::object::id
object_id_type id
Definition: object.hpp:69
graphene::chain::database
tracks the blockchain state in an extensible manner
Definition: database.hpp:70
graphene::chain::database::head_block_time
time_point_sec head_block_time() const
Definition: db_getter.cpp:67
asset_object.hpp
graphene::chain::account_object::blacklisting_accounts
flat_set< account_id_type > blacklisting_accounts
Definition: account_object.hpp:260
database.hpp
graphene::protocol::asset_options::whitelist_authorities
flat_set< account_id_type > whitelist_authorities
Definition: asset_ops.hpp:76
graphene::chain::asset_object
tracks the parameters of an asset
Definition: asset_object.hpp:75
graphene::protocol::asset_options::blacklist_authorities
flat_set< account_id_type > blacklist_authorities
Definition: asset_ops.hpp:81
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
account_object.hpp
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_COMMITTEE_ACCOUNT
#define GRAPHENE_COMMITTEE_ACCOUNT
Definition: config.hpp:140
graphene::chain::account_object::whitelisting_accounts
flat_set< account_id_type > whitelisting_accounts
Definition: account_object.hpp:237
graphene::db::object_id_type
Definition: object_id.hpp:30
graphene::db::abstract_object::get_id
object_id< SpaceID, TypeID > get_id() const
Definition: object.hpp:113
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