mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-04-28 03:00:18 -04:00
darkfid: purge current forks on network dc
This commit is contained in:
@@ -147,6 +147,7 @@ pub async fn consensus_init_task(
|
||||
Err(Error::NetworkNotConnected) => {
|
||||
// Sync node again
|
||||
*node.validator.synced.write().await = false;
|
||||
node.validator.consensus.purge_forks().await?;
|
||||
if !config.skip_sync {
|
||||
sync_task(&node, checkpoint).await?;
|
||||
} else {
|
||||
|
||||
@@ -204,8 +204,8 @@ async fn synced_peers(
|
||||
let _ = subscription.receive().await;
|
||||
subscription.unsubscribe().await;
|
||||
|
||||
info!(target: "darkfid::task::sync::synced_peers", "Sleeping a bit to allow for more nodes to connect...");
|
||||
sleep(node.p2p.settings().outbound_connect_timeout).await;
|
||||
info!(target: "darkfid::task::sync::synced_peers", "Sleeping for {comms_timeout} to allow for more nodes to connect...");
|
||||
sleep(comms_timeout).await;
|
||||
}
|
||||
|
||||
Ok(tips)
|
||||
|
||||
@@ -492,6 +492,16 @@ impl Consensus {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Auxiliary function to fully purge current forks and leave only a new empty fork.
|
||||
pub async fn purge_forks(&self) -> Result<()> {
|
||||
debug!(target: "validator::consensus::purge_forks", "Purging current forks...");
|
||||
let mut forks = self.forks.write().await;
|
||||
*forks = vec![Fork::new(self.blockchain.clone(), self.module.read().await.clone()).await?];
|
||||
drop(forks);
|
||||
debug!(target: "validator::consensus::purge_forks", "Forks purged!");
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
/// This struct represents a block proposal, used for consensus.
|
||||
|
||||
Reference in New Issue
Block a user