-
Notifications
You must be signed in to change notification settings - Fork 3
/
vote.rho
22 lines (22 loc) · 944 Bytes
/
vote.rho
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#define $ballot "calc"
#define $vote "lambda"
new ret, lockerCh, itemsCh, lookup(`rho:registry:lookup`), stdout(`rho:io:stdout`) in {
lookup!($locker_%%$myusername, *lockerCh) | for(locker <- lockerCh) {
locker!("get", $myprivkey.hexToBytes(), $locker_nonce_%%$myusername, *stdout, *itemsCh) |
for (@items <- itemsCh) {
if ( items.get("peek") == Nil ) {
stdout!("you do not have a peek channel for your inbox")
} else {
stdout!("getting voter") |
@{items.get("peek")}!("vote", $ballot, *ret) |
for( @{[voter]} <- ret ) {
@voter!("vote",$vote,*stdout,*ret) |
stdout!(["vote",$ballot,$myusername,"received"]) |
for (success <- ret ) {
@{items.get("receive")}!("vote", $ballot, *ret) |
stdout!(*success)
}
}
} |
stdout!(["#define $locker_nonce_" ++ $myusername, {$locker_nonce_%%$myusername + 1}])
} } }