Skip to content

Commit eb88056

Browse files
committed
consistent naming for custom_service_signal
1 parent 914030d commit eb88056

File tree

4 files changed

+18
-12
lines changed

4 files changed

+18
-12
lines changed

node/src/command.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -289,16 +289,21 @@ fn start_aura_service(arg_matches: &ArgMatches) -> Result<(), sc_cli::Error> {
289289
//
290290
// Passing this atomic bool is a hacky solution, allowing the node to set it to true to indicate
291291
// a Babe service should be spawned on exit instead of a regular shutdown.
292-
let babe_switch = Arc::new(AtomicBool::new(false));
293-
let babe_switch_clone = babe_switch.clone();
292+
let custom_service_signal = Arc::new(AtomicBool::new(false));
293+
let custom_service_signal_clone = custom_service_signal.clone();
294294
match runner.run_node_until_exit(|config| async move {
295295
let config = customise_config(arg_matches, config);
296-
service::build_full::<AuraConsensus>(config, cli.eth, cli.sealing, Some(babe_switch_clone))
297-
.await
296+
service::build_full::<AuraConsensus>(
297+
config,
298+
cli.eth,
299+
cli.sealing,
300+
Some(custom_service_signal_clone),
301+
)
302+
.await
298303
}) {
299304
Ok(()) => Ok(()),
300305
Err(e) => {
301-
if babe_switch.load(std::sync::atomic::Ordering::Relaxed) {
306+
if custom_service_signal.load(std::sync::atomic::Ordering::Relaxed) {
302307
start_babe_service(arg_matches)
303308
} else {
304309
Err(e.into())

node/src/consensus/aura_consensus.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,18 +195,18 @@ impl ConsensusMechanism for AuraConsensus {
195195
&self,
196196
task_manager: &mut TaskManager,
197197
client: Arc<FullClient>,
198-
triggered: Option<Arc<std::sync::atomic::AtomicBool>>,
198+
custom_service_signal: Option<Arc<std::sync::atomic::AtomicBool>>,
199199
sync_service: Arc<SyncingService<Block>>,
200200
) -> Result<(), sc_service::Error> {
201201
let client_clone = client.clone();
202-
let triggered_clone = triggered.clone();
202+
let custom_service_signal_clone = custom_service_signal.clone();
203203
let slot_duration = self.slot_duration(&client)?;
204204
task_manager.spawn_essential_handle().spawn(
205205
"babe-switch",
206206
None,
207207
Box::pin(async move {
208208
let client = client_clone;
209-
let triggered = triggered_clone;
209+
let custom_service_signal = custom_service_signal_clone;
210210
loop {
211211
// Check if the runtime is Babe once per block.
212212
if let Ok(c) = sc_consensus_babe::configuration(&*client) {
@@ -222,8 +222,9 @@ impl ConsensusMechanism for AuraConsensus {
222222
let syncing = sync_service.status().await.is_ok_and(|status| status.warp_sync.is_some() || status.state_sync.is_some());
223223
if !c.authorities.is_empty() && !syncing {
224224
log::info!("Babe runtime detected! Intentionally failing the essential handle `babe-switch` to trigger switch to Babe service.");
225-
if let Some(triggered) = triggered {
226-
triggered.store(true, std::sync::atomic::Ordering::SeqCst);
225+
// Signal that the node stopped due to the custom service exiting.
226+
if let Some(custom_service_signal) = custom_service_signal {
227+
custom_service_signal.store(true, std::sync::atomic::Ordering::SeqCst);
227228
};
228229
break;
229230
}

node/src/consensus/babe_consensus.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ impl ConsensusMechanism for BabeConsensus {
218218
&self,
219219
_task_manager: &mut TaskManager,
220220
_client: Arc<FullClient>,
221-
_triggered: Option<Arc<std::sync::atomic::AtomicBool>>,
221+
_custom_service_signal: Option<Arc<std::sync::atomic::AtomicBool>>,
222222
_sync_service: Arc<SyncingService<Block>>,
223223
) -> Result<(), sc_service::Error> {
224224
// No additional Babe handles required.

node/src/consensus/consensus_mechanism.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ pub trait ConsensusMechanism {
124124
&self,
125125
task_manager: &mut TaskManager,
126126
client: Arc<FullClient>,
127-
triggered: Option<Arc<AtomicBool>>,
127+
custom_service_signal: Option<Arc<AtomicBool>>,
128128
sync_service: Arc<SyncingService<Block>>,
129129
) -> Result<(), ServiceError>;
130130

0 commit comments

Comments
 (0)