BitShares-Core  7.0.2
BitShares blockchain node software and command-line wallet software
proposal_object.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 
29 
30 #include <boost/multi_index/composite_key.hpp>
31 
32 namespace graphene { namespace chain {
33  class database;
34 
40 class proposal_object : public abstract_object<proposal_object, protocol_ids, proposal_object_type>
41 {
42  public:
43  time_point_sec expiration_time;
46  flat_set<account_id_type> required_active_approvals;
47  flat_set<account_id_type> available_active_approvals;
48  flat_set<account_id_type> required_owner_approvals;
49  flat_set<account_id_type> available_owner_approvals;
50  flat_set<public_key_type> available_key_approvals;
51  account_id_type proposer;
52  std::string fail_reason;
53 
54  bool is_authorized_to_execute(database& db) const;
55 };
56 
69 {
70  public:
71  virtual void object_inserted( const object& obj ) override;
72  virtual void object_removed( const object& obj ) override;
73  virtual void about_to_modify( const object& before ) override;
74  virtual void object_modified( const object& after ) override;
75 
76  map<account_id_type, set<proposal_id_type> > _account_to_proposals;
77 
78  private:
79  void remove( account_id_type a, proposal_id_type p );
80  void insert_or_remove_delta( proposal_id_type p, const flat_set<account_id_type>& before,
81  const flat_set<account_id_type>& after );
82  flat_set<account_id_type> available_active_before_modify;
83  flat_set<account_id_type> available_owner_before_modify;
84 };
85 
86 struct by_expiration{};
87 typedef boost::multi_index_container<
89  indexed_by<
90  ordered_unique< tag< by_id >, member< object, object_id_type, &object::id > >,
91  ordered_unique<tag<by_expiration>,
92  composite_key<proposal_object,
93  member<proposal_object, time_point_sec, &proposal_object::expiration_time>,
94  member< object, object_id_type, &object::id >
95  >
96  >
97  >
100 
101 } } // graphene::chain
102 
104 
106 
graphene::chain::database
tracks the blockchain state in an extensible manner
Definition: database.hpp:70
graphene::chain::proposal_object::available_owner_approvals
flat_set< account_id_type > available_owner_approvals
Definition: proposal_object.hpp:49
graphene::chain::required_approval_index::about_to_modify
virtual void about_to_modify(const object &before) override
Definition: proposal_object.cpp:129
graphene::chain::proposal_object::expiration_time
time_point_sec expiration_time
Definition: proposal_object.hpp:43
FC_REFLECT_TYPENAME
FC_REFLECT_TYPENAME(fc::log_message)
generic_index.hpp
MAP_OBJECT_ID_TO_TYPE
#define MAP_OBJECT_ID_TO_TYPE(OBJECT)
Definition: object_id.hpp:93
graphene::protocol::transaction
groups operations that should be applied atomically
Definition: transaction.hpp:69
graphene::chain::proposal_object::proposed_transaction
transaction proposed_transaction
Definition: proposal_object.hpp:45
graphene::db::abstract_object
Definition: object.hpp:107
graphene::chain::proposal_index
generic_index< proposal_object, proposal_multi_index_container > proposal_index
Definition: proposal_object.hpp:99
graphene::chain::proposal_object::proposer
account_id_type proposer
Definition: proposal_object.hpp:51
graphene::chain::proposal_object::available_key_approvals
flat_set< public_key_type > available_key_approvals
Definition: proposal_object.hpp:50
graphene::chain::proposal_object::is_authorized_to_execute
bool is_authorized_to_execute(database &db) const
Definition: proposal_object.cpp:34
types.hpp
transaction.hpp
graphene::chain::by_expiration
Definition: proposal_object.hpp:86
GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION
#define GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION(type)
Definition: types.hpp:85
graphene::chain::required_approval_index
tracks all of the proposal objects that requrie approval of an individual account.
Definition: proposal_object.hpp:68
graphene::chain::required_approval_index::object_inserted
virtual void object_inserted(const object &obj) override
Definition: proposal_object.cpp:60
graphene::chain::required_approval_index::object_removed
virtual void object_removed(const object &obj) override
Definition: proposal_object.cpp:87
graphene::chain::proposal_multi_index_container
boost::multi_index_container< proposal_object, indexed_by< ordered_unique< tag< by_id >, member< object, object_id_type, &object::id > >, ordered_unique< tag< by_expiration >, composite_key< proposal_object, member< proposal_object, time_point_sec, &proposal_object::expiration_time >, member< object, object_id_type, &object::id > > > >> proposal_multi_index_container
Definition: proposal_object.hpp:98
graphene::chain::required_approval_index::object_modified
virtual void object_modified(const object &after) override
Definition: proposal_object.cpp:136
graphene::chain::proposal_object::required_active_approvals
flat_set< account_id_type > required_active_approvals
Definition: proposal_object.hpp:46
graphene::chain::proposal_object::required_owner_approvals
flat_set< account_id_type > required_owner_approvals
Definition: proposal_object.hpp:48
graphene::db::generic_index
Definition: generic_index.hpp:43
fc::optional
provides stack-based nullable value similar to boost::optional
Definition: optional.hpp:20
graphene::chain::proposal_object::available_active_approvals
flat_set< account_id_type > available_active_approvals
Definition: proposal_object.hpp:47
graphene::db::secondary_index
Definition: index.hpp:139
graphene::chain::proposal_object
tracks the approval of a partially approved transaction
Definition: proposal_object.hpp:40
graphene::chain::proposal_object::review_period_time
optional< time_point_sec > review_period_time
Definition: proposal_object.hpp:44
graphene::chain::proposal_object::fail_reason
std::string fail_reason
Definition: proposal_object.hpp:52
graphene::chain::required_approval_index::_account_to_proposals
map< account_id_type, set< proposal_id_type > > _account_to_proposals
Definition: proposal_object.hpp:76
graphene
Definition: api.cpp:48