Tidy attestation_production and create docstrings
This commit is contained in:
parent
2ed5f69448
commit
92753fa24e
@ -3,9 +3,10 @@ use types::{AttestationData, Hash256};
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum Error {
|
||||
SlotTooOld,
|
||||
PresentSlotUnknown,
|
||||
StateError,
|
||||
/// The `justified_block_root` is unknown. This is an internal error.
|
||||
UnknownJustifiedRoot,
|
||||
/// The `epoch_boundary_root` is unknown. This is an internal error.
|
||||
UnknownBoundaryRoot,
|
||||
}
|
||||
|
||||
impl<T, U> BeaconChain<T, U>
|
||||
@ -13,13 +14,14 @@ where
|
||||
T: ClientDB,
|
||||
U: SlotClock,
|
||||
{
|
||||
/// Produce an `AttestationData` that is valid for the present `slot` and given `shard`.
|
||||
pub fn produce_attestation_data(&self, shard: u64) -> Result<AttestationData, Error> {
|
||||
let justified_slot = self.justified_slot();
|
||||
let justified_block_root = self
|
||||
.state
|
||||
.read()
|
||||
.get_block_root(justified_slot, &self.spec)
|
||||
.ok_or_else(|| Error::SlotTooOld)?
|
||||
.ok_or_else(|| Error::UnknownJustifiedRoot)?
|
||||
.clone();
|
||||
|
||||
let epoch_boundary_root = self
|
||||
@ -29,7 +31,7 @@ where
|
||||
self.state.read().current_epoch_start_slot(&self.spec),
|
||||
&self.spec,
|
||||
)
|
||||
.ok_or_else(|| Error::SlotTooOld)?
|
||||
.ok_or_else(|| Error::UnknownBoundaryRoot)?
|
||||
.clone();
|
||||
|
||||
Ok(AttestationData {
|
||||
|
Loading…
Reference in New Issue
Block a user