Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unwraps in RPC pending_runtime_api #842

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Remove unwraps in RPC pending_runtime_api
  • Loading branch information
tgmichel committed Sep 5, 2022
commit 78817c1c6edd35edd1b101be170cad23e7b2499f
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);
}
return Ok(api);
} else {
return Err(internal_err(format!(
"Cannot get header for block {:?}",
best
)));
}
}