Dedup match_attestation_data

This commit is contained in:
dapplion
2024-06-17 16:26:47 +02:00
parent dd0d5e2d93
commit 3ec21a2435
2 changed files with 18 additions and 27 deletions

View File

@@ -716,6 +716,21 @@ pub struct AttesterData {
pub slot: Slot,
}
impl AttesterData {
pub fn match_attestation_data<E: EthSpec>(
&self,
attestation_data: &AttestationData,
spec: &ChainSpec,
) -> bool {
if spec.fork_name_at_slot::<E>(attestation_data.slot) < ForkName::Electra {
self.slot == attestation_data.slot && self.committee_index == attestation_data.index
} else {
// After electra `attestation_data.index` is set to 0 and does not match the duties
self.slot == attestation_data.index
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct ProposerData {
pub pubkey: PublicKeyBytes,