Skip to content

Commit

Permalink
unwrap to expect
Browse files Browse the repository at this point in the history
  • Loading branch information
yaziciahmet committed Jul 22, 2024
1 parent c7adbcc commit d0174f0
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions crates/ethereum-rpc/src/eth_subscription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,30 @@ pub async fn handle_new_heads_subscription<C: sov_modules_api::Context, Da: DaSe
let subscription = pending.accept().await.unwrap();
tokio::spawn(async move {
loop {
let block_number = rx.recv().await.unwrap();
let Ok(block_number) = rx.recv().await else {
// Connection closed
return;
};
let mut working_set = WorkingSet::<C>::new(ethereum.storage.clone());
let block = evm
.get_block_by_number(
Some(BlockNumberOrTag::Number(block_number)),
None,
&mut working_set,
)
.unwrap()
.unwrap();
.expect("Error querying block from evm")
.expect("Received signal but evm block is not found");

let msg = SubscriptionMessage::new(
subscription.method_name(),
subscription.subscription_id(),
&block,
)
.unwrap();
let _ = subscription.send(msg).await;
let Ok(_) = subscription.send(msg).await else {
// Connection closed
return;
};
}
});
}

0 comments on commit d0174f0

Please sign in to comment.