Skip to content

Commit 677920a

Browse files
committed
Changed unwrap or default for returning error
1 parent 25541ed commit 677920a

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

crates/networking/rpc/eth/client.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,15 @@ impl RpcHandler for Config {
100100

101101
async fn handle(&self, context: RpcApiContext) -> Result<Value, RpcErr> {
102102
let chain_config = context.storage.get_chain_config()?;
103-
let latest_block_timestamp = context
103+
let Some(latest_block) = context
104104
.storage
105105
.get_block_by_number(context.storage.get_latest_block_number().await?)
106106
.await?
107-
.unwrap_or_default()
108-
.header
109-
.timestamp;
107+
else {
108+
return Err(RpcErr::Internal("Failed to fetch latest block".to_string()));
109+
};
110+
111+
let latest_block_timestamp = latest_block.header.timestamp;
110112
let current_fork = chain_config.get_fork(latest_block_timestamp);
111113

112114
if current_fork < Fork::Paris {

0 commit comments

Comments
 (0)