mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-20 22:38:34 +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
@@ -151,6 +151,20 @@ impl Service {
|
||||
}
|
||||
}
|
||||
|
||||
/// Return byte representation of deposit and block caches.
|
||||
pub fn as_bytes(&self) -> Vec<u8> {
|
||||
self.inner.as_bytes()
|
||||
}
|
||||
|
||||
/// Recover the deposit and block caches from encoded bytes.
|
||||
pub fn from_bytes(bytes: &[u8], config: Config, log: Logger) -> Result<Self, String> {
|
||||
let inner = Inner::from_bytes(bytes, config)?;
|
||||
Ok(Self {
|
||||
inner: Arc::new(inner),
|
||||
log,
|
||||
})
|
||||
}
|
||||
|
||||
/// Provides access to the block cache.
|
||||
pub fn blocks(&self) -> &RwLock<BlockCache> {
|
||||
&self.inner.block_cache
|
||||
|
||||
Reference in New Issue
Block a user