lighthouse-pulse/lighthouse/state/active_state.rs

31 lines
679 B
Rust
Raw Normal View History

2018-08-10 00:48:03 +00:00
use super::utils::types::Hash256;
use super::attestation_record::AttestationRecord;
2018-07-06 07:54:07 +00:00
pub struct ActiveState {
2018-08-10 00:48:03 +00:00
pub pending_attestations: Vec<AttestationRecord>,
pub recent_block_hashes: Vec<Hash256>,
2018-07-06 07:54:07 +00:00
}
impl ActiveState {
2018-08-10 00:48:03 +00:00
/// Returns a new instance where all fields are empty vectors.
2018-07-11 08:14:40 +00:00
pub fn zero() -> Self {
Self {
2018-08-10 00:48:03 +00:00
pending_attestations: vec![],
recent_block_hashes: vec![],
2018-07-06 07:54:07 +00:00
}
}
}
2018-07-06 07:54:07 +00:00
#[cfg(test)]
mod tests {
use super::*;
#[test]
2018-08-10 00:48:03 +00:00
fn test_act_state_zero() {
2018-07-11 08:14:40 +00:00
let a = ActiveState::zero();
2018-08-10 00:48:03 +00:00
assert_eq!(a.pending_attestations.len(), 0);
assert_eq!(a.recent_block_hashes.len(), 0);
2018-07-09 05:17:34 +00:00
}
2018-07-06 07:54:07 +00:00
}