fix fetch state storage
@@ -507,21 +507,31 @@ pub fn get_tree_state(
.access_storage()
.map_err(|e| format_err!("Db connection failed for tree state: {}", e.to_string()))?;
- let (last_block, account_map) = storage.load_verified_state().map_err(|e| {
- format_err!(
- "get_tree_state: cant get last verified state: {}",
- e.to_string()
- )
- })?;
-
- let block = storage
- .get_block(last_block)
- .map_err(|e| format_err!("get_tree_state: cant get last block: {}", e.to_string()))?
- .ok_or_else(|| format_err!("get_tree_state: no last block - need to restart"))?;
- let unprocessed_prior_ops = block.processed_priority_ops.1;
+ let verified_state_result = storage.load_verified_state();
+ let (last_block, account_map) = match verified_state_result {
+ Err(err) => {
+ warn!("There are no last verified state in storage - will be updated from empty state. Reason: {:?}", err.to_string());
+ (0, AccountMap::default())
+ },
+ Ok(res) => {(res.0, res.1)}
+ };
- let fee_acc_id = block.fee_account;
+ let block_result = storage.get_block(last_block);
+ let block_opt = match block_result {
+ Err(err) => {
+ warn!("Cant get last block from storage. Reason: {:?}", err.to_string());
+ None
+ },
+ Ok(res) => {res}
+ };
+ let (unprocessed_prior_ops, fee_acc_id) = match block_opt {
+ None => {
+ warn!("There are no last block in storage");
+ (0, 0)
+ },
+ Some(block) => {(block.processed_priority_ops.1, block.fee_account)}
+ };
Ok((last_block, account_map, unprocessed_prior_ops, fee_acc_id))
}
