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)]
|
#[derive(Debug, PartialEq)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
SlotTooOld,
|
/// The `justified_block_root` is unknown. This is an internal error.
|
||||||
PresentSlotUnknown,
|
UnknownJustifiedRoot,
|
||||||
StateError,
|
/// The `epoch_boundary_root` is unknown. This is an internal error.
|
||||||
|
UnknownBoundaryRoot,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, U> BeaconChain<T, U>
|
impl<T, U> BeaconChain<T, U>
|
||||||
@ -13,13 +14,14 @@ where
|
|||||||
T: ClientDB,
|
T: ClientDB,
|
||||||
U: SlotClock,
|
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> {
|
pub fn produce_attestation_data(&self, shard: u64) -> Result<AttestationData, Error> {
|
||||||
let justified_slot = self.justified_slot();
|
let justified_slot = self.justified_slot();
|
||||||
let justified_block_root = self
|
let justified_block_root = self
|
||||||
.state
|
.state
|
||||||
.read()
|
.read()
|
||||||
.get_block_root(justified_slot, &self.spec)
|
.get_block_root(justified_slot, &self.spec)
|
||||||
.ok_or_else(|| Error::SlotTooOld)?
|
.ok_or_else(|| Error::UnknownJustifiedRoot)?
|
||||||
.clone();
|
.clone();
|
||||||
|
|
||||||
let epoch_boundary_root = self
|
let epoch_boundary_root = self
|
||||||
@ -29,7 +31,7 @@ where
|
|||||||
self.state.read().current_epoch_start_slot(&self.spec),
|
self.state.read().current_epoch_start_slot(&self.spec),
|
||||||
&self.spec,
|
&self.spec,
|
||||||
)
|
)
|
||||||
.ok_or_else(|| Error::SlotTooOld)?
|
.ok_or_else(|| Error::UnknownBoundaryRoot)?
|
||||||
.clone();
|
.clone();
|
||||||
|
|
||||||
Ok(AttestationData {
|
Ok(AttestationData {
|
||||||
|
Loading…
Reference in New Issue
Block a user