Skip to content

Commit

Permalink
Remove unwraps in RPC pending_runtime_api (#842)
Browse files Browse the repository at this point in the history
* Remove unwraps in RPC `pending_runtime_api`

* clippy
  • Loading branch information
tgmichel committed Sep 6, 2022
1 parent 233173e commit 7c96d95
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions client/rpc/src/eth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,13 +482,19 @@ where
.map(|in_pool_tx| in_pool_tx.data().clone())
.collect::<Vec<<B as BlockT>::Extrinsic>>();
// Manually initialize the overlay.
let header = client.header(best).unwrap().unwrap();
let parent_hash = BlockId::Hash(*header.parent_hash());
api.initialize_block(&parent_hash, &header)
.map_err(|e| internal_err(format!("Runtime api access error: {:?}", e)))?;
// Apply the ready queue to the best block's state.
for xt in xts {
let _ = api.apply_extrinsic(&best, xt);
}
Ok(api)
if let Ok(Some(header)) = client.header(best) {
let parent_hash = BlockId::Hash(*header.parent_hash());
api.initialize_block(&parent_hash, &header)
.map_err(|e| internal_err(format!("Runtime api access error: {:?}", e)))?;
// Apply the ready queue to the best block's state.
for xt in xts {
let _ = api.apply_extrinsic(&best, xt);
}
Ok(api)
} else {
Err(internal_err(format!(
"Cannot get header for block {:?}",
best
)))
}
}

0 comments on commit 7c96d95

Please sign in to comment.