Rename AttestationRecord -> Attestation

This commit is contained in:
Paul Hauner
2018-12-12 12:16:11 +11:00
parent 7259e1d7b6
commit 4d0641636e
7 changed files with 57 additions and 51 deletions

View File

@@ -1,9 +1,9 @@
use super::Hash256;
use super::{AttestationRecord, SpecialRecord};
use super::{Attestation, SpecialRecord};
#[derive(Debug, PartialEq)]
pub struct ActiveState {
pub pending_attestations: Vec<AttestationRecord>,
pub pending_attestations: Vec<Attestation>,
pub pending_specials: Vec<SpecialRecord>,
pub recent_block_hashes: Vec<Hash256>,
pub randao_mix: Hash256,

View File

@@ -11,14 +11,14 @@ pub const MIN_SSZ_ATTESTION_RECORD_LENGTH: usize = {
};
#[derive(Debug, Clone, PartialEq)]
pub struct AttestationRecord {
pub struct Attestation {
pub data: AttestationData,
pub participation_bitfield: Bitfield,
pub custody_bitfield: Bitfield,
pub aggregate_sig: AggregateSignature,
}
impl Encodable for AttestationRecord {
impl Encodable for Attestation {
fn ssz_append(&self, s: &mut SszStream) {
s.append(&self.data);
s.append(&self.participation_bitfield);
@@ -27,7 +27,7 @@ impl Encodable for AttestationRecord {
}
}
impl Decodable for AttestationRecord {
impl Decodable for Attestation {
fn ssz_decode(bytes: &[u8], i: usize) -> Result<(Self, usize), DecodeError> {
let (data, i) = AttestationData::ssz_decode(bytes, i)?;
let (participation_bitfield, i) = Bitfield::ssz_decode(bytes, i)?;
@@ -46,7 +46,7 @@ impl Decodable for AttestationRecord {
}
}
impl AttestationRecord {
impl Attestation {
pub fn zero() -> Self {
Self {
data: AttestationData::zero(),
@@ -64,7 +64,7 @@ mod tests {
#[test]
pub fn test_attestation_record_min_ssz_length() {
let ar = AttestationRecord::zero();
let ar = Attestation::zero();
let ssz = ssz_encode(&ar);
assert_eq!(ssz.len(), MIN_SSZ_ATTESTION_RECORD_LENGTH);
@@ -72,7 +72,7 @@ mod tests {
#[test]
pub fn test_attestation_record_ssz_round_trip() {
let original = AttestationRecord {
let original = Attestation {
data: AttestationData::zero(),
participation_bitfield: Bitfield::from_bytes(&vec![17; 42][..]),
custody_bitfield: Bitfield::from_bytes(&vec![18; 12][..]),
@@ -80,7 +80,7 @@ mod tests {
};
let ssz = ssz_encode(&original);
let (decoded, _) = AttestationRecord::ssz_decode(&ssz, 0).unwrap();
let (decoded, _) = Attestation::ssz_decode(&ssz, 0).unwrap();
assert_eq!(original, decoded);
}

View File

@@ -1,4 +1,4 @@
use super::attestation_record::AttestationRecord;
use super::attestation::Attestation;
use super::special_record::SpecialRecord;
use super::ssz::{Decodable, DecodeError, Encodable, SszStream};
use super::Hash256;
@@ -23,7 +23,7 @@ pub struct BeaconBlock {
pub ancestor_hashes: Vec<Hash256>,
pub active_state_root: Hash256,
pub crystallized_state_root: Hash256,
pub attestations: Vec<AttestationRecord>,
pub attestations: Vec<Attestation>,
pub specials: Vec<SpecialRecord>,
}

View File

@@ -5,7 +5,7 @@ extern crate ssz;
pub mod active_state;
pub mod attestation_data;
pub mod attestation_record;
pub mod attestation;
pub mod beacon_block;
pub mod beacon_state;
pub mod candidate_pow_receipt_root_record;
@@ -25,7 +25,7 @@ use std::collections::HashMap;
pub use active_state::ActiveState;
pub use attestation_data::AttestationData;
pub use attestation_record::AttestationRecord;
pub use attestation::Attestation;
pub use beacon_block::BeaconBlock;
pub use beacon_state::BeaconState;
pub use chain_config::ChainConfig;