|
@@ -37,8 +37,14 @@ pub async fn consensus_task(node: Arc<Darkfid>, ex: Arc<smol::Executor<'static>>
|
|
|
let proposals_sub = node.subscribers.get("proposals").unwrap();
|
|
let proposals_sub = node.subscribers.get("proposals").unwrap();
|
|
|
let subscription = proposals_sub.sub.clone().subscribe().await;
|
|
let subscription = proposals_sub.sub.clone().subscribe().await;
|
|
|
|
|
|
|
|
- // Create channels so threads can signal each other
|
|
|
|
|
- let (gc_sender, gc_stop_signal) = smol::channel::bounded(1);
|
|
|
|
|
|
|
+ // Create the garbage collection task using a dummy task
|
|
|
|
|
+ let gc_task = StoppableTask::new();
|
|
|
|
|
+ gc_task.clone().start(
|
|
|
|
|
+ async { Ok(()) },
|
|
|
|
|
+ |_| async { /* Do nothing */ },
|
|
|
|
|
+ Error::GarbageCollectionTaskStopped,
|
|
|
|
|
+ ex.clone(),
|
|
|
|
|
+ );
|
|
|
|
|
|
|
|
loop {
|
|
loop {
|
|
|
subscription.receive().await;
|
|
subscription.receive().await;
|
|
@@ -53,17 +59,17 @@ pub async fn consensus_task(node: Arc<Darkfid>, ex: Arc<smol::Executor<'static>>
|
|
|
}
|
|
}
|
|
|
block_sub.notify(JsonValue::Array(notif_blocks)).await;
|
|
block_sub.notify(JsonValue::Array(notif_blocks)).await;
|
|
|
|
|
|
|
|
- // Invoke detached garbage collection task
|
|
|
|
|
- gc_sender.send(()).await?;
|
|
|
|
|
- StoppableTask::new().start(
|
|
|
|
|
- garbage_collect_task(node.clone(), gc_stop_signal.clone()),
|
|
|
|
|
|
|
+ // Invoke the detached garbage collection task
|
|
|
|
|
+ gc_task.clone().stop().await;
|
|
|
|
|
+ gc_task.clone().start(
|
|
|
|
|
+ garbage_collect_task(node.clone()),
|
|
|
|res| async {
|
|
|res| async {
|
|
|
match res {
|
|
match res {
|
|
|
- Ok(()) => { /* Do nothing */ }
|
|
|
|
|
|
|
+ Ok(()) | Err(Error::GarbageCollectionTaskStopped) => { /* Do nothing */ }
|
|
|
Err(e) => error!(target: "darkfid", "Failed starting garbage collection task: {}", e),
|
|
Err(e) => error!(target: "darkfid", "Failed starting garbage collection task: {}", e),
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
- Error::MinerTaskStopped,
|
|
|
|
|
|
|
+ Error::GarbageCollectionTaskStopped,
|
|
|
ex.clone(),
|
|
ex.clone(),
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|