-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd_poll.gpsl
38 lines (30 loc) · 985 Bytes
/
add_poll.gpsl
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
fn add_poll() {
let user = read_value("./data/user.gvalue");
let poll = read_value("./data/poll.gvalue");
write("./data/user.gvalue", "");
write("./data/poll.gvalue", "");
let users = read_value("./data/users.gvalue");
let polls = read_value("./data/polls.gvalue");
if (users[0] == "") {
users[0] = user;
let tmp_e: Vec<eep> = vec(encrypt(0));
tmp_e[0] = encrypt(poll[0]);
for (let i = 1; i < length(poll); i += 1) {
tmp_e = push(tmp_e, encrypt(poll[i]));
}
polls[0] = tmp_e;
} else {
users = push(users, user);
let tmp_e: Vec<eep> = vec(encrypt(0));
tmp_e[0] = encrypt(poll[0]);
for (let i = 1; i < length(poll); i += 1) {
tmp_e = push(tmp_e, encrypt(poll[i]));
}
polls = push(polls, tmp_e);
}
write_value("./data/users.gvalue", users);
write_value("./data/polls.gvalue", polls);
}
fn main() {
add_poll();
}