mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-21 14:58:31 +00:00
Implement tree states & hierarchical state DB
This commit is contained in:
@@ -178,8 +178,8 @@ impl StoreItem for SszEth1 {
|
||||
DBColumn::Eth1Cache
|
||||
}
|
||||
|
||||
fn as_store_bytes(&self) -> Vec<u8> {
|
||||
self.as_ssz_bytes()
|
||||
fn as_store_bytes(&self) -> Result<Vec<u8>, StoreError> {
|
||||
Ok(self.as_ssz_bytes())
|
||||
}
|
||||
|
||||
fn from_store_bytes(bytes: &[u8]) -> Result<Self, StoreError> {
|
||||
@@ -1021,6 +1021,7 @@ mod test {
|
||||
|
||||
mod collect_valid_votes {
|
||||
use super::*;
|
||||
use types::VList;
|
||||
|
||||
fn get_eth1_data_vec(n: u64, block_number_offset: u64) -> Vec<(Eth1Data, BlockNumber)> {
|
||||
(0..n)
|
||||
@@ -1068,12 +1069,14 @@ mod test {
|
||||
|
||||
let votes_to_consider = get_eth1_data_vec(slots, 0);
|
||||
|
||||
*state.eth1_data_votes_mut() = votes_to_consider[0..slots as usize / 4]
|
||||
.iter()
|
||||
.map(|(eth1_data, _)| eth1_data)
|
||||
.cloned()
|
||||
.collect::<Vec<_>>()
|
||||
.into();
|
||||
*state.eth1_data_votes_mut() = VList::new(
|
||||
votes_to_consider[0..slots as usize / 4]
|
||||
.iter()
|
||||
.map(|(eth1_data, _)| eth1_data)
|
||||
.cloned()
|
||||
.collect::<Vec<_>>(),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let votes =
|
||||
collect_valid_votes(&state, &votes_to_consider.clone().into_iter().collect());
|
||||
@@ -1097,12 +1100,14 @@ mod test {
|
||||
.expect("should have some eth1 data")
|
||||
.clone();
|
||||
|
||||
*state.eth1_data_votes_mut() = vec![duplicate_eth1_data.clone(); 4]
|
||||
.iter()
|
||||
.map(|(eth1_data, _)| eth1_data)
|
||||
.cloned()
|
||||
.collect::<Vec<_>>()
|
||||
.into();
|
||||
*state.eth1_data_votes_mut() = VList::new(
|
||||
vec![duplicate_eth1_data.clone(); 4]
|
||||
.iter()
|
||||
.map(|(eth1_data, _)| eth1_data)
|
||||
.cloned()
|
||||
.collect::<Vec<_>>(),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let votes = collect_valid_votes(&state, &votes_to_consider.into_iter().collect());
|
||||
assert_votes!(
|
||||
|
||||
Reference in New Issue
Block a user