BitShares-Core  6.1.0
BitShares blockchain implementation and command-line interface 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 
tracks all of the proposal objects that requrie approval of an individual account.
flat_set< account_id_type > available_active_approvals
tracks the blockchain state in an extensible manner
Definition: database.hpp:70
Definition: api.cpp:48
#define MAP_OBJECT_ID_TO_TYPE(OBJECT)
Definition: object_id.hpp:93
flat_set< account_id_type > required_owner_approvals
groups operations that should be applied atomically
Definition: transaction.hpp:69
flat_set< account_id_type > available_owner_approvals
provides stack-based nullable value similar to boost::optional
Definition: optional.hpp:20
FC_REFLECT_TYPENAME(fc::log_message)
#define GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION(type)
Definition: types.hpp:85
generic_index< proposal_object, proposal_multi_index_container > proposal_index
map< account_id_type, set< proposal_id_type > > _account_to_proposals
optional< time_point_sec > review_period_time
flat_set< account_id_type > required_active_approvals
bool is_authorized_to_execute(database &db) const
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
flat_set< public_key_type > available_key_approvals
tracks the approval of a partially approved transaction