BitShares-Core  4.0.0
BitShares blockchain implementation and command-line interface software
proposal.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  */
26 
27 #include <fc/io/raw.hpp>
28 
29 namespace graphene { namespace protocol {
30 
32 {
33  // TODO move this method to unit tests as it is not useful
35  op.expiration_time = head_block_time + global_params.maximum_proposal_lifetime;
37  return op;
38 }
39 
41 {
42  FC_ASSERT( !proposed_ops.empty() );
43  for( const auto& op : proposed_ops ) operation_validate( op.op );
44 }
45 
47 {
49 }
50 
52 {
53  FC_ASSERT(fee.amount >= 0);
54  FC_ASSERT(!(active_approvals_to_add.empty() && active_approvals_to_remove.empty() &&
55  owner_approvals_to_add.empty() && owner_approvals_to_remove.empty() &&
56  key_approvals_to_add.empty() && key_approvals_to_remove.empty()));
57  for( auto a : active_approvals_to_add )
58  {
59  FC_ASSERT(active_approvals_to_remove.find(a) == active_approvals_to_remove.end(),
60  "Cannot add and remove approval at the same time.");
61  }
62  for( auto a : owner_approvals_to_add )
63  {
64  FC_ASSERT(owner_approvals_to_remove.find(a) == owner_approvals_to_remove.end(),
65  "Cannot add and remove approval at the same time.");
66  }
67  for( auto a : key_approvals_to_add )
68  {
69  FC_ASSERT(key_approvals_to_remove.find(a) == key_approvals_to_remove.end(),
70  "Cannot add and remove approval at the same time.");
71  }
72 }
73 
75 {
76  FC_ASSERT( fee.amount >= 0 );
77 }
78 
80 {
82 }
83 
84 void proposal_update_operation::get_required_authorities( vector<authority>& o )const
85 {
86  authority auth;
87  for( const auto& k : key_approvals_to_add )
88  auth.key_auths[k] = 1;
89  for( const auto& k : key_approvals_to_remove )
90  auth.key_auths[k] = 1;
91  auth.weight_threshold = auth.key_auths.size();
92 
93  if( auth.weight_threshold > 0 )
94  o.emplace_back( std::move(auth) );
95 }
96 
97 void proposal_update_operation::get_required_active_authorities( flat_set<account_id_type>& a )const
98 {
99  for( const auto& i : active_approvals_to_add ) a.insert(i);
100  for( const auto& i : active_approvals_to_remove ) a.insert(i);
101 }
102 
103 void proposal_update_operation::get_required_owner_authorities( flat_set<account_id_type>& a )const
104 {
105  for( const auto& i : owner_approvals_to_add ) a.insert(i);
106  for( const auto& i : owner_approvals_to_remove ) a.insert(i);
107 }
108 
109 } } // graphene::protocol
110 
Identifies a weighted set of keys and accounts that must approve operations.
Definition: authority.hpp:34
Definition: api.cpp:56
The proposal_delete_operation deletes an existing transaction proposalThis operation allows the early...
Definition: proposal.hpp:156
share_type calculate_fee(const fee_parameters_type &k) const
Definition: proposal.cpp:79
uint32_t committee_proposal_review_period
minimum time in seconds that a proposed transaction requiring committee authority may not be signed...
void get_required_owner_authorities(flat_set< account_id_type > &) const
Definition: proposal.cpp:103
share_type calculate_fee(const fee_parameters_type &k) const
Definition: proposal.cpp:46
uint32_t maximum_proposal_lifetime
maximum lifetime in seconds for proposed transactions to be kept, before expiring ...
The proposal_create_operation creates a transaction proposal, for use in multi-sig scenariosCreates a...
Definition: proposal.hpp:70
flat_map< public_key_type, weight_type > key_auths
Definition: authority.hpp:121
void get_required_active_authorities(flat_set< account_id_type > &) const
Definition: proposal.cpp:97
size_t pack_size(const T &v)
Definition: raw.hpp:757
void operation_validate(const operation &op)
Definition: operations.cpp:98
#define FC_ASSERT(TEST,...)
Checks a condition and throws an assert_exception if the test is FALSE.
Definition: exception.hpp:345
void get_required_authorities(vector< authority > &) const
Definition: proposal.cpp:84
#define GRAPHENE_IMPLEMENT_EXTERNAL_SERIALIZATION(type)
Definition: types.hpp:74
The proposal_update_operation updates an existing transaction proposalThis operation allows accounts ...
Definition: proposal.hpp:119
static uint64_t calculate_data_fee(uint64_t bytes, uint64_t price_per_kbyte)
Definition: operations.cpp:33
static proposal_create_operation committee_proposal(const chain_parameters &param, fc::time_point_sec head_block_time)
Definition: proposal.cpp:31