Scorum
types.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <fc/container/flat_fwd.hpp>
4 #include <fc/io/varint.hpp>
5 #include <fc/io/enum_type.hpp>
6 #include <fc/crypto/sha224.hpp>
7 #include <fc/crypto/ripemd160.hpp>
8 #include <fc/crypto/elliptic.hpp>
9 #include <fc/reflect/reflect.hpp>
10 #include <fc/reflect/variant.hpp>
11 #include <fc/optional.hpp>
12 #include <fc/safe.hpp>
13 #include <fc/container/flat.hpp>
14 #include <fc/string.hpp>
15 #include <fc/fixed_string.hpp>
16 #include <fc/io/raw.hpp>
17 #include <fc/uint128.hpp>
18 #include <fc/static_variant.hpp>
19 #include <fc/smart_ref_fwd.hpp>
20 #include <fc/time.hpp>
21 #include <fc/safe.hpp>
22 
23 #include <boost/multiprecision/cpp_int.hpp>
24 #include <boost/uuid/uuid.hpp>
25 
26 #include <memory>
27 #include <vector>
28 #include <deque>
29 #include <cstdint>
30 
31 namespace scorum {
32 
33 using fc::uint128_t;
34 typedef boost::multiprecision::uint256_t u256;
35 typedef boost::multiprecision::uint512_t u512;
36 
37 using fc::enum_type;
38 using fc::flat_map;
39 using fc::flat_set;
40 using fc::optional;
41 using fc::safe;
42 using fc::signed_int;
43 using fc::smart_ref;
44 using fc::static_variant;
45 using fc::time_point;
46 using fc::time_point_sec;
47 using fc::unsigned_int;
48 using fc::variant;
49 using fc::variant_object;
50 using fc::ecc::commitment_type;
51 using fc::ecc::range_proof_info;
52 using fc::ecc::range_proof_type;
53 using uuid_type = boost::uuids::uuid;
54 struct void_t
55 {
56 };
57 
58 namespace protocol {
59 
60 typedef fc::ecc::private_key private_key_type;
61 typedef fc::sha256 chain_id_type;
62 typedef fc::fixed_string_16 account_name_type;
63 typedef fc::ripemd160 block_id_type;
64 typedef fc::ripemd160 checksum_type;
65 typedef fc::ripemd160 transaction_id_type;
66 typedef fc::sha256 digest_type;
67 typedef fc::ecc::compact_signature signature_type;
68 typedef uint16_t authority_weight_type;
69 typedef uint16_t percent_type;
70 typedef int16_t vote_weight_type;
71 
72 using share_value_type = int64_t;
73 using share_type = fc::safe<share_value_type>;
74 
76 {
77  struct binary_key
78  {
80  {
81  }
82  uint32_t check = 0;
83  fc::ecc::public_key_data data;
84  };
85  fc::ecc::public_key_data key_data;
87  public_key_type(const fc::ecc::public_key_data& data);
88  public_key_type(const fc::ecc::public_key& pubkey);
89  explicit public_key_type(const std::string& base58str);
90  operator fc::ecc::public_key_data() const;
91  operator fc::ecc::public_key() const;
92  explicit operator std::string() const;
93  friend bool operator==(const public_key_type& p1, const fc::ecc::public_key& p2);
94  friend bool operator==(const public_key_type& p1, const public_key_type& p2);
95  friend bool operator<(const public_key_type& p1, const public_key_type& p2)
96  {
97  return p1.key_data < p2.key_data;
98  }
99  friend bool operator!=(const public_key_type& p1, const public_key_type& p2);
100 };
101 
103 {
104  struct binary_key
105  {
107  {
108  }
109  uint32_t check = 0;
110  fc::ecc::extended_key_data data;
111  };
112 
113  fc::ecc::extended_key_data key_data;
114 
116  extended_public_key_type(const fc::ecc::extended_key_data& data);
117  extended_public_key_type(const fc::ecc::extended_public_key& extpubkey);
118  explicit extended_public_key_type(const std::string& base58str);
119  operator fc::ecc::extended_public_key() const;
120  explicit operator std::string() const;
121  friend bool operator==(const extended_public_key_type& p1, const fc::ecc::extended_public_key& p2);
122  friend bool operator==(const extended_public_key_type& p1, const extended_public_key_type& p2);
123  friend bool operator!=(const extended_public_key_type& p1, const extended_public_key_type& p2);
124 };
125 
127 {
128  struct binary_key
129  {
131  {
132  }
133  uint32_t check = 0;
134  fc::ecc::extended_key_data data;
135  };
136 
137  fc::ecc::extended_key_data key_data;
138 
140  extended_private_key_type(const fc::ecc::extended_key_data& data);
141  extended_private_key_type(const fc::ecc::extended_private_key& extprivkey);
142  explicit extended_private_key_type(const std::string& base58str);
143  operator fc::ecc::extended_private_key() const;
144  explicit operator std::string() const;
145  friend bool operator==(const extended_private_key_type& p1, const fc::ecc::extended_private_key& p2);
146  friend bool operator==(const extended_private_key_type& p1, const extended_private_key_type& p2);
147  friend bool operator!=(const extended_private_key_type& p1, const extended_private_key_type& p2);
148 };
149 
150 enum class curve_id
151 {
152  quadratic,
153  linear,
154  square_root,
155  power1dot5
156 };
157 
158 enum class budget_type
159 {
160  post,
161  banner
162 };
163 } // namespace protocol
164 } // namespace scorum
165 
166 namespace fc {
167 void to_variant(const scorum::protocol::public_key_type& var, fc::variant& vo);
168 void from_variant(const fc::variant& var, scorum::protocol::public_key_type& vo);
169 void to_variant(const scorum::protocol::extended_public_key_type& var, fc::variant& vo);
170 void from_variant(const fc::variant& var, scorum::protocol::extended_public_key_type& vo);
171 void to_variant(const scorum::protocol::extended_private_key_type& var, fc::variant& vo);
172 void from_variant(const fc::variant& var, scorum::protocol::extended_private_key_type& vo);
173 void to_variant(const boost::uuids::uuid&, fc::variant&);
174 void from_variant(const fc::variant&, boost::uuids::uuid&);
175 } // namespace fc
176 
183 FC_REFLECT(boost::uuids::uuid, (data))
184 
185 FC_REFLECT_ENUM(scorum::protocol::curve_id, (quadratic)(linear)(square_root)(power1dot5))
187 
FC_REFLECT_ENUM(scorum::protocol::game_status,(created)(started)(finished)(resolved)(expired)(cancelled)) namespace fc
Definition: game_status.hpp:18
FC_REFLECT(appender_args,(appender)(stream)) FC_REFLECT_DERIVED(file_appender_args
Definition: game.cpp:4
void to_variant(const game_type &game, fc::variant &var)
Definition: game.cpp:8
void from_variant(const fc::variant &var, game_type &game)
Definition: game.cpp:12
@ post
Rate limiting posting reward eligibility over time.
fc::ecc::private_key private_key_type
Definition: types.hpp:60
fc::ripemd160 transaction_id_type
Definition: types.hpp:65
fc::safe< share_value_type > share_type
Definition: types.hpp:73
fc::fixed_string_16 account_name_type
Definition: types.hpp:62
fc::sha256 chain_id_type
Definition: types.hpp:61
int16_t vote_weight_type
Definition: types.hpp:70
fc::ripemd160 checksum_type
Definition: types.hpp:64
uint16_t authority_weight_type
Definition: types.hpp:68
int64_t share_value_type
Definition: types.hpp:72
uint16_t percent_type
Definition: types.hpp:69
fc::sha256 digest_type
Definition: types.hpp:66
fc::ripemd160 block_id_type
Definition: types.hpp:63
fc::ecc::compact_signature signature_type
Definition: types.hpp:67
Definition: asset.cpp:15
boost::multiprecision::uint512_t u512
Definition: types.hpp:35
boost::multiprecision::uint256_t u256
Definition: types.hpp:34
boost::uuids::uuid uuid_type
Definition: types.hpp:53
fc::ecc::extended_key_data key_data
Definition: types.hpp:137
friend bool operator==(const extended_private_key_type &p1, const fc::ecc::extended_private_key &p2)
friend bool operator!=(const extended_private_key_type &p1, const extended_private_key_type &p2)
Definition: types.cpp:178
fc::ecc::extended_key_data key_data
Definition: types.hpp:113
friend bool operator==(const extended_public_key_type &p1, const fc::ecc::extended_public_key &p2)
Definition: types.cpp:113
friend bool operator!=(const extended_public_key_type &p1, const extended_public_key_type &p2)
Definition: types.cpp:123
fc::ecc::public_key_data key_data
Definition: types.hpp:85
friend bool operator!=(const public_key_type &p1, const public_key_type &p2)
Definition: types.cpp:68
friend bool operator==(const public_key_type &p1, const fc::ecc::public_key &p2)
Definition: types.cpp:58
friend bool operator<(const public_key_type &p1, const public_key_type &p2)
Definition: types.hpp:95