lighthouse-pulse/lighthouse/state/attestation_record.rs

38 lines
1.0 KiB
Rust
Raw Normal View History

2018-08-10 00:48:03 +00:00
use super::utils::types::{ Hash256, Bitfield };
use super::utils::bls::{ AggregateSignature };
2018-09-10 05:51:44 +00:00
use super::ssz::{ Encodable, SszStream };
2018-08-10 00:48:03 +00:00
pub struct AttestationRecord {
2018-08-10 01:22:15 +00:00
pub slot: u64,
pub shard_id: u16,
pub oblique_parent_hashes: Vec<Hash256>,
pub shard_block_hash: Hash256,
pub attester_bitfield: Bitfield,
pub aggregate_sig: Option<AggregateSignature>,
2018-08-10 00:48:03 +00:00
}
2018-09-10 05:51:44 +00:00
impl Encodable for AttestationRecord {
fn ssz_append(&self, s: &mut SszStream) {
s.append(&self.slot);
s.append(&self.shard_id);
s.append_vec(&self.oblique_parent_hashes);
s.append(&self.shard_block_hash);
s.append_vec(&self.attester_bitfield.to_be_vec());
2018-09-10 05:51:44 +00:00
// TODO: add aggregate signature
}
}
2018-08-10 00:48:03 +00:00
impl AttestationRecord {
pub fn zero() -> Self {
Self {
slot: 0,
shard_id: 0,
oblique_parent_hashes: vec![],
shard_block_hash: Hash256::zero(),
attester_bitfield: Bitfield::new(),
aggregate_sig: None,
}
}
}