Skip to content

Commit ffabe70

Browse files
chore(notifier+fetcher+signer+rpc): use spawn macro for non-crucial tasks
1 parent 2497bb1 commit ffabe70

File tree

4 files changed

+24
-16
lines changed

4 files changed

+24
-16
lines changed

core/fetcher/src/fetcher.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,12 @@ impl<C: Collection> Fetcher<C> {
4444
resolver.clone(),
4545
);
4646

47-
tokio::spawn(async move {
48-
waiter.run_until_shutdown(origin_fetcher.start()).await;
49-
});
47+
spawn!(
48+
async move {
49+
waiter.run_until_shutdown(origin_fetcher.start()).await;
50+
},
51+
"FETCHER: shutdown waiter"
52+
);
5053

5154
let worker = FetcherWorker::<C> {
5255
origin_tx,

core/notifier/src/lib.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,10 @@ impl<C: Collection> NotifierInterface<C> for Notifier<C> {
7878
self.notify.epoch_changed.subscribe(),
7979
self.waiter.wait_for_shutdown_owned(),
8080
);
81-
tokio::spawn(before_epoch_change(
82-
sender,
83-
self.query_runner.clone(),
84-
duration,
85-
epoch_changed,
86-
));
81+
spawn!(
82+
before_epoch_change(sender, self.query_runner.clone(), duration, epoch_changed,),
83+
"NOTIFIER: subscribe before epoch change"
84+
);
8785
BroadcastSub(rx, self.waiter.wait_for_shutdown_owned())
8886
}
8987
}

core/rpc/src/event.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use lightning_interfaces::spawn;
12
use lightning_interfaces::types::Event;
23
use tokio::sync::{broadcast, mpsc};
34

@@ -19,10 +20,13 @@ impl EventDistributor {
1920
broadcast_tx: broadcast_tx.clone(),
2021
};
2122

22-
tokio::spawn(async move {
23-
Self::forward(&mut event_rx, &broadcast_tx).await;
24-
tracing::info!("consensous dropped the tx");
25-
});
23+
spawn!(
24+
async move {
25+
Self::forward(&mut event_rx, &broadcast_tx).await;
26+
tracing::info!("consensous dropped the tx");
27+
},
28+
"RPC: forward"
29+
);
2630

2731
this
2832
}

core/signer/src/lib.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,12 @@ impl<C: Collection> Signer<C> {
104104
guard.init_state(chain_id, nonce, secondary_nonce);
105105
drop(guard);
106106

107-
tokio::spawn(async move {
108-
new_block_task(node_index, worker, subscriber, query_runner).await;
109-
});
107+
spawn!(
108+
async move {
109+
new_block_task(node_index, worker, subscriber, query_runner).await;
110+
},
111+
"SIGNER: new block task"
112+
);
110113
}
111114
}
112115

0 commit comments

Comments
 (0)