mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-14 10:22:38 +00:00
Persist eth1 cache (#760)
* Add intermediate structures for bytes conversion * Expose byte conversion methods from `Eth1Service` * Add eth1 ssz containers * Fix type errors * Load eth1 cache on restart * Fix compile errors * Update Cargo.lock * Add comments and minor formatting * Add test for eth1 cache persistence * Restrict Deposit and Block cache field visibility * Add checks * Fix `SszDepositCache` check * Implement Encode/Decode directly on `BlockCache`
This commit is contained in:
committed by
Paul Hauner
parent
a8da36b913
commit
661ef65de8
@@ -1,3 +1,4 @@
|
||||
use ssz_derive::{Decode, Encode};
|
||||
use std::ops::RangeInclusive;
|
||||
use types::{Eth1Data, Hash256};
|
||||
|
||||
@@ -17,7 +18,7 @@ pub enum Error {
|
||||
/// A block of the eth1 chain.
|
||||
///
|
||||
/// Contains all information required to add a `BlockCache` entry.
|
||||
#[derive(Debug, PartialEq, Clone, Eq, Hash)]
|
||||
#[derive(Debug, PartialEq, Clone, Eq, Hash, Encode, Decode)]
|
||||
pub struct Eth1Block {
|
||||
pub hash: Hash256,
|
||||
pub timestamp: u64,
|
||||
@@ -38,7 +39,7 @@ impl Eth1Block {
|
||||
|
||||
/// Stores block and deposit contract information and provides queries based upon the block
|
||||
/// timestamp.
|
||||
#[derive(Debug, PartialEq, Clone, Default)]
|
||||
#[derive(Debug, PartialEq, Clone, Default, Encode, Decode)]
|
||||
pub struct BlockCache {
|
||||
blocks: Vec<Eth1Block>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user