Skip to content

Commit

Permalink
Always use an aborter
Browse files Browse the repository at this point in the history
  • Loading branch information
james-chf committed Aug 16, 2022
1 parent 08552ed commit b7c377e
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions apps/src/lib/node/ledger/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,12 @@ async fn run_aux(config: config::Ledger, wasm_dir: PathBuf) {
// we want any Ethereum endpoint set in the environment to override the
// one set in the config
let ethereum_url = std::env::var(ENV_VAR_ETHEREUM_URL).ok();
// On panic or exit, the `Drop` of `AbortSender` will
// send abort message
let aborter_for_eth = Aborter {
sender: abort_send_for_eth,
who: "Ethereum",
};
let (ethereum_url, ethereum_node, abort_sender) = match ethereum_url {
Some(ethereum_url) => {
tracing::info!(
Expand All @@ -339,6 +345,7 @@ async fn run_aux(config: config::Ledger, wasm_dir: PathBuf) {
"Received abort signal that was intended for Ethereum \
node"
);
drop(aborter_for_eth);
Ok(())
});
let (abort_sender, _) = tokio::sync::oneshot::channel();
Expand All @@ -358,19 +365,12 @@ async fn run_aux(config: config::Ledger, wasm_dir: PathBuf) {

// run geth in the background
let handle = tokio::spawn(async move {
// On panic or exit, the `Drop` of `AbortSender` will
// send abort message
let aborter = Aborter {
sender: abort_send_for_eth,
who: "Ethereum",
};

let res = ethereum_node::run(ethereum_node, eth_abort_recv)
.map_err(Error::Ethereum)
.await;
tracing::info!("Ethereum fullnode is no longer running.");

drop(aborter);
drop(aborter_for_eth);
res
});
(ethereum_url, handle, abort_sender)
Expand Down

0 comments on commit b7c377e

Please sign in to comment.