2019-01-28 04:50:42 +00:00
|
|
|
use super::{BeaconChain, ClientDB, SlotClock};
|
|
|
|
pub use crate::attestation_aggregator::{ProcessError as AggregatorError, ProcessOutcome};
|
|
|
|
use crate::canonical_head::Error as HeadError;
|
2019-01-28 05:21:33 +00:00
|
|
|
use types::FreeAttestation;
|
2019-01-28 04:50:42 +00:00
|
|
|
|
|
|
|
#[derive(Debug, PartialEq)]
|
|
|
|
pub enum Error {
|
|
|
|
PresentSlotUnknown,
|
|
|
|
AggregatorError(AggregatorError),
|
|
|
|
HeadError(HeadError),
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<T, U> BeaconChain<T, U>
|
|
|
|
where
|
|
|
|
T: ClientDB,
|
|
|
|
U: SlotClock,
|
|
|
|
{
|
|
|
|
pub fn process_free_attestation(
|
|
|
|
&self,
|
2019-01-28 05:21:33 +00:00
|
|
|
free_attestation: FreeAttestation,
|
2019-01-28 04:50:42 +00:00
|
|
|
) -> Result<ProcessOutcome, Error> {
|
|
|
|
self.attestation_aggregator
|
|
|
|
.write()
|
2019-02-01 03:48:09 +00:00
|
|
|
.process_free_attestation(&self.state.read(), &free_attestation, &self.spec)
|
2019-01-28 04:50:42 +00:00
|
|
|
.map_err(|e| e.into())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<AggregatorError> for Error {
|
|
|
|
fn from(e: AggregatorError) -> Error {
|
|
|
|
Error::AggregatorError(e)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<HeadError> for Error {
|
|
|
|
fn from(e: HeadError) -> Error {
|
|
|
|
Error::HeadError(e)
|
|
|
|
}
|
|
|
|
}
|