Skip to content

Commit

Permalink
Fix zksync_core crate
Browse files Browse the repository at this point in the history
  • Loading branch information
popzxc committed Mar 28, 2022
1 parent 96725e1 commit 8c770f7
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl<'a, 'b> StateRestoreDb for StateRestoreStorage<'a, 'b> {
async fn load_last_cached_block(&mut self) -> Option<BlockNumber> {
self.storage
.chain()
.block_schema()
.tree_cache_schema_bincode()
.get_last_block_with_account_tree_cache()
.await
.expect("Can't load the last block with cache")
Expand Down Expand Up @@ -87,26 +87,25 @@ impl<'a, 'b> StateRestoreDb for StateRestoreStorage<'a, 'b> {
) -> SparseMerkleTreeSerializableCacheBN256 {
let cache = self.storage
.chain()
.block_schema()
.tree_cache_schema_bincode()
.get_account_tree_cache_block(block)
.await
.expect("Can't load account tree cache")
.unwrap_or_else(|| {
panic!("Account tree cache was requested for block {}, for which it was checked to exist", block)
});
serde_json::from_value(cache).expect("Unable to decode tree cache")
SparseMerkleTreeSerializableCacheBN256::decode_bincode(&cache)
}

async fn store_account_tree_cache(
&mut self,
block: BlockNumber,
account_tree_cache: SparseMerkleTreeSerializableCacheBN256,
) {
let encoded_tree_cache = serde_json::to_string(&account_tree_cache)
.expect("Unable to encode account tree cache");
let encoded_tree_cache = account_tree_cache.encode_bincode();
self.storage
.chain()
.block_schema()
.tree_cache_schema_bincode()
.store_account_tree_cache(block, encoded_tree_cache)
.await
.expect("Unable to store account tree cache in the database");
Expand Down

0 comments on commit 8c770f7

Please sign in to comment.