Skip to content

Commit

Permalink
Remove panics from service's create_inherent_data_providers function (
Browse files Browse the repository at this point in the history
#126)

wow, we really can handle these errors gracefully.
  • Loading branch information
JoshOrndorff authored Oct 14, 2023
1 parent dde3d65 commit bad03b6
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,14 +244,12 @@ pub fn new_full(config: Configuration) -> Result<TaskManager, ServiceError> {
block_import,
proposer_factory,
create_inherent_data_providers: move |parent_hash, ()| {
let parent_block = client_for_cidp
.clone()
.block(parent_hash)
.expect("Block backend should not error.")
.expect("Parent block should be found in database for authoring to work.")
.block;
let maybe_parent_block = client_for_cidp.clone().block(parent_hash);

async move {
let parent_block = maybe_parent_block?
.ok_or(sp_blockchain::Error::UnknownBlock(parent_hash.to_string()))?
.block;
let parent_idp =
tuxedo_core::inherents::ParentBlockInherentDataProvider(parent_block);
let timestamp = sp_timestamp::InherentDataProvider::from_system_time();
Expand Down

0 comments on commit bad03b6

Please sign in to comment.