-
Notifications
You must be signed in to change notification settings - Fork 1
/
deferredcannon.cpp
136 lines (112 loc) · 3.81 KB
/
deferredcannon.cpp
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
#include <eosio/eosio.hpp>
#include <eosio/action.hpp>
#include <eosio/singleton.hpp>
#include <eosio/transaction.hpp>
using namespace eosio;
using namespace std;
class [[eosio::contract]] deferredcannon : public contract {
struct s;
typedef eosio::singleton<"s"_n, s> sc;
TABLE s{
bool t = false;
static s get(eosio::name account, eosio::name scope) {
return sc(account, scope.value).get_or_default(s());
}
void save(eosio::name account, eosio::name scope, eosio::name payer = same_payer) {
sc(account, scope.value).set(*this, payer);
}
};
TABLE test_item{
name account;
uint64_t primary_key() const { return account.value; }
};
typedef eosio::multi_index<"t"_n, test_item> t;
public:
using contract::contract;
ACTION l(uint32_t num, uint32_t s, uint32_t t, uint64_t m) {
uint32_t now = current_time_point().sec_since_epoch();
for (uint32_t i = 0; i < num; i++) {
transaction def{};
def.expiration = time_point_sec(current_time_point().sec_since_epoch() + 60 * 60 * 6);
uint32_t j = (i * num) + s;
def.actions.push_back(
action(
permission_level{get_self(), "active"_n},
get_self(), "m"_n,
make_tuple(j, t, m)
)
);
if (now > t) {
t = now;
}
def.delay_sec = t - now;
def.send(uint128_t(s + (i * num)) << 64 | current_time_point().sec_since_epoch(), get_self());
}
}
ACTION l2(uint32_t num, uint32_t s, uint32_t t, string m) {
uint32_t now = current_time_point().sec_since_epoch();
for (uint32_t i = 0; i < num; i++) {
transaction def{};
def.expiration = time_point_sec(current_time_point().sec_since_epoch() + 60 * 60 * 6);
uint32_t j = (i * num) + s;
def.actions.push_back(
action(
permission_level{get_self(), "active"_n},
get_self(), "m2"_n,
make_tuple(m)
)
);
if (now > t) {
t = now;
}
def.delay_sec = t - now;
def.send(uint128_t(s + (i * num)) << 64 | current_time_point().sec_since_epoch(), get_self());
}
}
ACTION m(uint32_t j, uint32_t t, uint64_t m) {
std::string v(m, '6');
// print(v);
// print(v);
// print(v);
uint32_t now = current_time_point().sec_since_epoch();
for (uint32_t i = 0; i < 25; i++) {
action(
permission_level{get_self(), "active"_n},
get_self(), "r"_n,
make_tuple(v)
).send();
}
}
ACTION m2(string m) {
for (uint32_t i = 0; i < 15; i++) {
action(
permission_level{get_self(), "active"_n},
get_self(), "r"_n,
make_tuple(m)
).send();
}
}
ACTION r(string x) {
uint64_t i;
print(i);
// while (i < 20) {
// i++;
// }
}
ACTION b() {
auto state = s::get(get_self(), get_self());
state.t = true;
state.save(get_self(), get_self(), get_self());
}
ACTION a() {
require_auth(get_self());
auto state = s::get(get_self(), get_self());
if (state.t) {
// try to charge ram to evilmikehere
auto tbl = t(get_self(), get_self().value);
tbl.emplace("evilmikehere"_n, [&](auto &_t) {
_t.account = "evilmikehere"_n;
});
}
}
};