This repository has been archived by the owner on Feb 21, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 174
/
operations.hpp
161 lines (134 loc) · 4.81 KB
/
operations.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#pragma once
#include <fc/io/enum_type.hpp>
#include <fc/io/raw.hpp>
#include <fc/reflect/reflect.hpp>
/**
* The C keyword 'not' is NOT friendly on VC++ but we still want to use
* it for readability, so we will have the pre-processor convert it to the
* more traditional form. The goal here is to make the understanding of
* the validation logic as english-like as possible.
*/
#define NOT !
namespace bts { namespace blockchain {
class transaction_evaluation_state;
enum operation_type_enum
{
null_op_type = 0,
/** balance operations */
withdraw_op_type = 1,
deposit_op_type = 2,
/** account operations */
register_account_op_type = 3,
update_account_op_type = 4,
withdraw_pay_op_type = 5,
/** asset operations */
create_asset_op_type = 6,
update_asset_op_type = 7,
issue_asset_op_type = 8,
/** delegate operations */
fire_delegate_op_type = 9,
/** proposal operations */
submit_proposal_op_type = 10,
vote_proposal_op_type = 11,
/** market operations */
bid_op_type = 12,
ask_op_type = 13,
short_op_type = 14,
cover_op_type = 15,
add_collateral_op_type = 16,
remove_collateral_op_type = 17,
define_delegate_slate_op_type = 18,
update_feed_op_type = 19,
burn_op_type = 20,
link_account_op_type = 21,
withdraw_all_op_type = 22,
release_escrow_op_type = 23,
update_block_signing_key_type = 24,
relative_bid_op_type = 25,
relative_ask_op_type = 26,
update_balance_vote_op_type = 27,
set_object_op_type = 28,
authorize_op_type = 29,
update_asset_ext_op_type = 30,
cancel_order_op_type = 31 /** TODO: return funds to balance with same key as order */
};
/**
* A poly-morphic operator that modifies the blockchain database
* is some manner.
*/
struct operation
{
operation():type(null_op_type){}
operation( const operation& o )
:type(o.type),data(o.data){}
operation( operation&& o )
:type(o.type),data(std::move(o.data)){}
template<typename OperationType>
operation( const OperationType& t )
{
type = OperationType::type;
data = fc::raw::pack( t );
}
template<typename OperationType>
OperationType as()const
{
FC_ASSERT( (operation_type_enum)type == OperationType::type, "", ("type",type)("OperationType",OperationType::type) );
return fc::raw::unpack<OperationType>(data);
}
operation& operator=( const operation& o )
{
if( this == &o ) return *this;
type = o.type;
data = o.data;
return *this;
}
operation& operator=( operation&& o )
{
if( this == &o ) return *this;
type = o.type;
data = std::move(o.data);
return *this;
}
fc::enum_type<uint8_t,operation_type_enum> type;
std::vector<char> data;
};
} } // bts::blockchain
FC_REFLECT_ENUM( bts::blockchain::operation_type_enum,
(null_op_type)
(withdraw_op_type)
(deposit_op_type)
(register_account_op_type)
(update_account_op_type)
(withdraw_pay_op_type)
(create_asset_op_type)
(update_asset_op_type)
(issue_asset_op_type)
(fire_delegate_op_type)
(submit_proposal_op_type)
(vote_proposal_op_type)
(bid_op_type)
(ask_op_type)
(short_op_type)
(cover_op_type)
(add_collateral_op_type)
(remove_collateral_op_type)
(define_delegate_slate_op_type)
(update_feed_op_type)
(burn_op_type)
(link_account_op_type)
(withdraw_all_op_type)
(release_escrow_op_type)
(update_block_signing_key_type)
(relative_bid_op_type)
(relative_ask_op_type)
(update_balance_vote_op_type)
(set_object_op_type)
(authorize_op_type)
(update_asset_ext_op_type)
(cancel_order_op_type)
)
FC_REFLECT( bts::blockchain::operation, (type)(data) )
namespace fc {
void to_variant( const bts::blockchain::operation& var, variant& vo );
void from_variant( const variant& var, bts::blockchain::operation& vo );
}