-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy patheosdacrandom.hpp
More file actions
94 lines (68 loc) · 1.94 KB
/
eosdacrandom.hpp
File metadata and controls
94 lines (68 loc) · 1.94 KB
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
#include <eosiolib/eosio.hpp>
#include <eosiolib/crypto.h>
#include <string>
#include <vector>
#include <tuple>
using namespace eosio;
using namespace std;
// @abi table
struct seedinfo
{
name datafeeder;
string seed;
string hash;
uint64_t primary_key() const { return datafeeder.value; }
EOSLIB_SERIALIZE( seedinfo, (datafeeder) (seed) (hash))
};
typedef eosio::multi_index<N(seedinfo), seedinfo> seed_table;
// @abi table
struct requestinfo
{
uint64_t timestamp;
string orderid;
EOSLIB_SERIALIZE( requestinfo, (timestamp) (orderid) )
};
// @abi table
struct geterinfo
{
name consumer;
vector<requestinfo> requestinfos;
uint64_t primary_key() const { return consumer.value; }
EOSLIB_SERIALIZE( geterinfo, (consumer) (requestinfos) )
};
typedef eosio::multi_index<N(geterinfo), geterinfo> geter_table;
// void getrandom(string orderid, int64_t number) {}
class eosdacrandom : public eosio::contract
{
public:
eosdacrandom(account_name name);
~eosdacrandom();
// @abi action
void setsize(uint64_t size);
// @abi action
void setreserved(vector<name> dfs);
// @abi action
void sendseed(name datafeeder, string seed);
// @abi action
void sendhash(name datafeeder, string hash);
// @abi action
void regrequest(name consumer, string orderid);
public:
// @abi table
struct seedconfig
{
account_name owner;
uint64_t target_size;
uint64_t hash_count;
uint64_t seed_match;
uint64_t primary_key() const { return owner; }
EOSLIB_SERIALIZE( seedconfig, (owner) (target_size) (hash_count) (seed_match) )
};
typedef eosio::multi_index<N(seedconfig), seedconfig> seedconfig_table;
private:
string one_seed();
bool seedsmatch();
string cal_sha256_str(string word);
string make_sha256_str(int index, string orderid, string seed);
void dispatch_request();
};