mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-04-28 03:00:18 -04:00
darkfid: properly stop rpc client on termination
This commit is contained in:
@@ -345,7 +345,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
||||
|
||||
let task = StoppableTask::new();
|
||||
task.clone().start(
|
||||
miner_task(darkfid, recipient, blockchain_config.skip_sync, ex.clone()),
|
||||
miner_task(darkfid.clone(), recipient, blockchain_config.skip_sync, ex.clone()),
|
||||
|res| async move {
|
||||
match res {
|
||||
Ok(()) | Err(Error::MinerTaskStopped) => { /* Do nothing */ }
|
||||
@@ -360,7 +360,7 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
||||
} else {
|
||||
let task = StoppableTask::new();
|
||||
task.clone().start(
|
||||
consensus_task(darkfid, ex.clone()),
|
||||
consensus_task(darkfid.clone(), ex.clone()),
|
||||
|res| async move {
|
||||
match res {
|
||||
Ok(()) | Err(Error::ConsensusTaskStopped) => { /* Do nothing */ }
|
||||
@@ -392,5 +392,10 @@ async fn realmain(args: Args, ex: Arc<smol::Executor<'static>>) -> Result<()> {
|
||||
let flushed_bytes = sled_db.flush_async().await?;
|
||||
info!(target: "darkfid", "Flushed {} bytes", flushed_bytes);
|
||||
|
||||
if let Some(ref rpc_client) = darkfid.rpc_client {
|
||||
info!(target: "darkfid", "Stopping JSON-RPC client...");
|
||||
rpc_client.lock().await.client.stop().await;
|
||||
};
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user