2018-03-14 17:03:21 -07:00
|
|
|
//! Binary Byzantine agreement protocol from a common coin protocol.
|
2018-05-01 10:12:05 -07:00
|
|
|
|
2018-05-02 03:57:28 -07:00
|
|
|
use std::collections::VecDeque;
|
|
|
|
use proto::AgreementMessage;
|
|
|
|
|
2018-05-01 10:12:05 -07:00
|
|
|
pub struct Agreement {
|
|
|
|
input: Option<bool>
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Agreement {
|
|
|
|
pub fn set_input(&mut self, input: bool) {
|
|
|
|
self.input = Some(input);
|
|
|
|
}
|
2018-05-02 03:57:28 -07:00
|
|
|
|
|
|
|
pub fn has_input(&self) -> bool {
|
|
|
|
self.input.is_some()
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Receive input from a remote node.
|
|
|
|
pub fn on_input(&self, _message: AgreementMessage) ->
|
|
|
|
Result<VecDeque<AgreementMessage>, Error>
|
|
|
|
{
|
|
|
|
Err(Error::NotImplemented)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone, Debug)]
|
|
|
|
pub enum Error {
|
|
|
|
NotImplemented
|
2018-05-01 10:12:05 -07:00
|
|
|
}
|