Scorum
atomicswap_objects.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <fc/fixed_string.hpp>
4 
7 
10 
11 #include <boost/multi_index/composite_key.hpp>
12 
13 #include <numeric>
14 
16 
17 namespace scorum {
18 namespace chain {
19 
22 
23 enum atomicswap_contract_type : bool
24 {
25  atomicswap_contract_initiator = 0,
26  atomicswap_contract_participant,
27 };
28 
29 class atomicswap_contract_object : public object<atomicswap_contract_object_type, atomicswap_contract_object>
30 {
31 public:
33  CHAINBASE_DEFAULT_DYNAMIC_CONSTRUCTOR(atomicswap_contract_object, (metadata)(secret_hash)(secret))
34 
35  id_type id;
36 
37  atomicswap_contract_type type = atomicswap_contract_initiator;
38 
40 
42  asset amount = asset(0, SCORUM_SYMBOL);
43 
44  fc::shared_string metadata;
45 
46  fc::shared_string secret_hash;
47  fc::shared_string secret;
48  hash_index_type contract_hash;
49 
50  time_point_sec created = time_point_sec::min();
51  time_point_sec deadline = time_point_sec::min();
52 };
53 
54 struct by_owner_name;
55 struct by_recipient_name;
56 struct by_contract_hash;
57 
58 typedef shared_multi_index_container<atomicswap_contract_object,
59  indexed_by<ordered_unique<tag<by_id>,
60  member<atomicswap_contract_object,
62  &atomicswap_contract_object::id>>,
63  ordered_non_unique<tag<by_owner_name>,
64  member<atomicswap_contract_object,
67  ordered_non_unique<tag<by_recipient_name>,
68  member<atomicswap_contract_object,
70  &atomicswap_contract_object::to>>,
71  ordered_unique<tag<by_contract_hash>,
72  member<atomicswap_contract_object,
74  &atomicswap_contract_object::contract_hash>>>>
75  atomicswap_contract_index;
76 }
77 }
78 
79 FC_REFLECT_ENUM(scorum::chain::atomicswap_contract_type,
80  (atomicswap_contract_initiator)(atomicswap_contract_participant))
81 
82 FC_REFLECT(scorum::chain::atomicswap_contract_object,
83  (id)(type)(owner)(to)(amount)(metadata)(secret_hash)(secret)(contract_hash)(created)(deadline))
84 
85 CHAINBASE_SET_INDEX_TYPE(scorum::chain::atomicswap_contract_object, scorum::chain::atomicswap_contract_index)
#define SCORUM_SYMBOL
Definition: config.hpp:102
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
oid< atomicswap_contract_object > atomicswap_contract_id_type
fc::fixed_string_32 hash_index_type
fc::fixed_string_16 account_name_type
Definition: types.hpp:62
Definition: asset.cpp:15