types: PendingAttestation::from_attestation
This commit is contained in:
parent
518359e898
commit
99dbed86f1
@ -322,13 +322,7 @@ pub fn process_attestations(
|
|||||||
|
|
||||||
// Update the state in series.
|
// Update the state in series.
|
||||||
for attestation in attestations {
|
for attestation in attestations {
|
||||||
let pending_attestation = PendingAttestation {
|
let pending_attestation = PendingAttestation::from_attestation(attestation, state.slot);
|
||||||
data: attestation.data.clone(),
|
|
||||||
aggregation_bitfield: attestation.aggregation_bitfield.clone(),
|
|
||||||
custody_bitfield: attestation.custody_bitfield.clone(),
|
|
||||||
inclusion_slot: state.slot,
|
|
||||||
};
|
|
||||||
|
|
||||||
let attestation_epoch = attestation.data.slot.epoch(spec.slots_per_epoch);
|
let attestation_epoch = attestation.data.slot.epoch(spec.slots_per_epoch);
|
||||||
|
|
||||||
if attestation_epoch == state.current_epoch(spec) {
|
if attestation_epoch == state.current_epoch(spec) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use crate::test_utils::TestRandom;
|
use crate::test_utils::TestRandom;
|
||||||
use crate::{AttestationData, Bitfield, Slot};
|
use crate::{Attestation, AttestationData, Bitfield, Slot};
|
||||||
use rand::RngCore;
|
use rand::RngCore;
|
||||||
use serde_derive::{Deserialize, Serialize};
|
use serde_derive::{Deserialize, Serialize};
|
||||||
use ssz_derive::{Decode, Encode, TreeHash};
|
use ssz_derive::{Decode, Encode, TreeHash};
|
||||||
@ -16,6 +16,18 @@ pub struct PendingAttestation {
|
|||||||
pub inclusion_slot: Slot,
|
pub inclusion_slot: Slot,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl PendingAttestation {
|
||||||
|
/// Create a `PendingAttestation` from an `Attestation`, at the given `inclusion_slot`.
|
||||||
|
pub fn from_attestation(attestation: &Attestation, inclusion_slot: Slot) -> Self {
|
||||||
|
PendingAttestation {
|
||||||
|
data: attestation.data.clone(),
|
||||||
|
aggregation_bitfield: attestation.aggregation_bitfield.clone(),
|
||||||
|
custody_bitfield: attestation.custody_bitfield.clone(),
|
||||||
|
inclusion_slot,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
Loading…
Reference in New Issue
Block a user