BitShares-Core  7.0.2
BitShares blockchain node software and command-line wallet software
base.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 
28 
29 #include <fc/thread/future.hpp>
30 
31 namespace graphene { namespace protocol {
32  struct asset;
33  struct authority;
34 
86  struct void_result{};
87 
89  {
90  flat_set<object_id_type> new_objects;
91  flat_set<object_id_type> updated_objects;
92  flat_set<object_id_type> removed_objects;
93  };
94 
96  {
97  vector<asset> paid;
98  vector<asset> received;
99  vector<asset> fees;
100  };
101 
103  {
111  };
112 
114 
116  /* 0 */ void_result,
117  /* 1 */ object_id_type,
118  /* 2 */ asset,
119  /* 3 */ generic_operation_result,
122  >;
123 
125  {
126  virtual ~base_operation() = default;
127  template<typename T>
128  share_type calculate_fee(const T& params)const
129  {
130  return params.fee;
131  }
132  virtual void get_required_authorities( vector<authority>& )const{ /* do nothing by default */ }
133  virtual void get_required_active_authorities( flat_set<account_id_type>& )const{ /* do nothing by default */ }
134  virtual void get_required_owner_authorities( flat_set<account_id_type>& )const{ /* do nothing by default */ }
135  virtual void validate()const{ /* do nothing by default */ }
136  fc::optional< fc::future<void> > validate_parallel( uint32_t skip )const;
137 
138  static uint64_t calculate_data_fee( uint64_t bytes, uint64_t price_per_kbyte );
139  };
140 
148 
157 
159 
160 } } // graphene::protocol
161 
167 FC_REFLECT( graphene::protocol::generic_operation_result, (new_objects)(updated_objects)(removed_objects) )
168 FC_REFLECT( graphene::protocol::generic_exchange_operation_result, (paid)(received)(fees) )
169 FC_REFLECT( graphene::protocol::extendable_operation_result_dtl,
170  (impacted_accounts)(new_objects)(updated_objects)(removed_objects)(paid)(received)(fees) )
171 
172 GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::generic_operation_result ) // impl in operations.cpp
173 // impl in operations.cpp
174 GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::generic_exchange_operation_result )
175 // impl in operations.cpp
176 GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION( graphene::protocol::extendable_operation_result_dtl )
graphene::protocol::extension
Definition: ext.hpp:36
graphene::protocol::extendable_operation_result_dtl::paid
optional< vector< asset > > paid
Definition: base.hpp:108
fc::static_variant< void_result, object_id_type, asset, generic_operation_result, generic_exchange_operation_result, extendable_operation_result >
FC_REFLECT_TYPENAME
FC_REFLECT_TYPENAME(fc::log_message)
ext.hpp
graphene::protocol::base_operation
Definition: base.hpp:124
graphene::protocol::base_operation::calculate_fee
share_type calculate_fee(const T &params) const
Definition: base.hpp:128
graphene::protocol::extendable_operation_result_dtl::received
optional< vector< asset > > received
Definition: base.hpp:109
graphene::protocol::base_operation::calculate_data_fee
static uint64_t calculate_data_fee(uint64_t bytes, uint64_t price_per_kbyte)
Definition: operations.cpp:33
types.hpp
graphene::protocol::base_operation::~base_operation
virtual ~base_operation()=default
graphene::protocol::generic_exchange_operation_result
Definition: base.hpp:95
graphene::protocol::base_operation::get_required_owner_authorities
virtual void get_required_owner_authorities(flat_set< account_id_type > &) const
Definition: base.hpp:134
graphene::protocol::base_operation::get_required_authorities
virtual void get_required_authorities(vector< authority > &) const
Definition: base.hpp:132
GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION
#define GRAPHENE_DECLARE_EXTERNAL_SERIALIZATION(type)
Definition: types.hpp:85
graphene::protocol::extendable_operation_result_dtl::new_objects
optional< flat_set< object_id_type > > new_objects
Definition: base.hpp:105
graphene::protocol::extendable_operation_result_dtl::removed_objects
optional< flat_set< object_id_type > > removed_objects
Definition: base.hpp:107
graphene::protocol::generic_exchange_operation_result::received
vector< asset > received
Definition: base.hpp:98
graphene::protocol::generic_operation_result::updated_objects
flat_set< object_id_type > updated_objects
Definition: base.hpp:91
graphene::protocol::base_operation::get_required_active_authorities
virtual void get_required_active_authorities(flat_set< account_id_type > &) const
Definition: base.hpp:133
future.hpp
graphene::protocol::base_operation::validate_parallel
fc::optional< fc::future< void > > validate_parallel(uint32_t skip) const
Definition: operations.cpp:40
graphene::db::object_id_type
Definition: object_id.hpp:30
graphene::protocol::generic_exchange_operation_result::paid
vector< asset > paid
Definition: base.hpp:97
graphene::protocol::generic_operation_result::new_objects
flat_set< object_id_type > new_objects
Definition: base.hpp:90
graphene::protocol::base_operation::validate
virtual void validate() const
Definition: base.hpp:135
graphene::protocol::extendable_operation_result_dtl::updated_objects
optional< flat_set< object_id_type > > updated_objects
Definition: base.hpp:106
graphene::protocol::extendable_operation_result_dtl::fees
optional< vector< asset > > fees
Definition: base.hpp:110
graphene::protocol::generic_exchange_operation_result::fees
vector< asset > fees
Definition: base.hpp:99
FC_REFLECT
#define FC_REFLECT(TYPE, MEMBERS)
Specializes fc::reflector for TYPE.
Definition: reflect.hpp:388
fc::optional
provides stack-based nullable value similar to boost::optional
Definition: optional.hpp:20
fc::static_variant::flat_set_type
flat_set< static_variant, type_lt > flat_set_type
Definition: static_variant.hpp:132
graphene::protocol::asset
Definition: asset.hpp:31
graphene::protocol::void_result
Definition: base.hpp:86
graphene::protocol::extendable_operation_result_dtl::impacted_accounts
optional< flat_set< account_id_type > > impacted_accounts
Definition: base.hpp:104
graphene::protocol::generic_operation_result
Definition: base.hpp:88
graphene::protocol::extendable_operation_result_dtl
Definition: base.hpp:102
graphene
Definition: api.cpp:48
graphene::protocol::generic_operation_result::removed_objects
flat_set< object_id_type > removed_objects
Definition: base.hpp:92
graphene::protocol::extensions_type
future_extensions::flat_set_type extensions_type
Definition: base.hpp:156
fc::safe
Definition: safe.hpp:26