Registry / Framework

framework · v0.1.2
Label Consensus
Require a second independent host-provided label to agree or route the sample for adjudication.
Use Label Consensus
use vendor::label_consensus::label_consensus;
Run the example
nest demo label_consensus@0.1.2
blyxc native-run label_consensus-demo/main.blyx
Example source and expected output
use std::cli;
use std::text;
use vendor::label_consensus::label_consensus;
fn main() {
let arguments = cli_args();
if args_len(arguments) > 0 {
if args_len(arguments) % 2 != 0 {
stderr_line("Expected event and value pairs");
process_exit(2);
}
let mut live = label_consensus_start();
let mut i = 0;
while i < args_len(arguments) {
let input = args_at(arguments, i + 1);
if !text_is_number(input) {
stderr_line("Expected a whole numeric event value");
process_exit(2);
}
live = label_consensus_step(live, args_at(arguments, i), text_number(input));
let command = label_consensus_command(live);
println!(command);
if command == "reject" { process_exit(1); }
i += 2;
}
return;
}
let mut state = label_consensus_start();
state = label_consensus_step(state, "first", 3.0);
println!(label_consensus_command(state));
state = label_consensus_step(state, "vote", 4.0);
println!(label_consensus_command(state));
state = label_consensus_step(state, "rule", 4.0);
println!(label_consensus_command(state));
state = label_consensus_step(state, "reopen", 0.0);
println!(label_consensus_command(state));
}
Expected output
request_blind_vote
request_adjudication
write_ruling
erase_consensus
Published versions
| Version | Package | Source commit | SHA-256 |
|---|---|---|---|
| 0.1.2 | Download ZIP · Browse files | 4e49e72508 | ac25a6f989b46eaee7b0ecae21cd60f44e8cc2322991b1d0ce1f4ca15cd0cee3 |
| 0.1.1 | Download ZIP · Browse files | 3475a60312 | cb93e6066cbeb318223e0f67b5c3a0d855468eaa7edde7236cca346a31bab0f9 |
| 0.1.0 | Download ZIP · Browse files | 6349f23784 | 30e2b661c5ef081c94c87ac35574c5f9b16ae14d7c6dbc5efcb74c1fb84a8e89 |