mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-04-28 03:00:18 -04:00
event-graph: Flush sled on prune task stop.
This commit is contained in:
@@ -91,7 +91,7 @@ impl EventGraph {
|
||||
/// * `days_rotation` marks the lifetime of the DAG before it's pruned.
|
||||
pub async fn new(
|
||||
p2p: P2pPtr,
|
||||
sled_db: &sled::Db,
|
||||
sled_db: sled::Db,
|
||||
dag_tree_name: &str,
|
||||
days_rotation: u64,
|
||||
ex: Arc<Executor<'_>>,
|
||||
@@ -133,7 +133,7 @@ impl EventGraph {
|
||||
prune_task.clone().start(
|
||||
self_.clone().dag_prune(days_rotation),
|
||||
|_| async move {
|
||||
self__.clone()._handle_stop().await;
|
||||
self__.clone()._handle_stop(sled_db).await;
|
||||
},
|
||||
Error::DetachedTaskStopped,
|
||||
ex.clone(),
|
||||
@@ -142,8 +142,9 @@ impl EventGraph {
|
||||
Ok(self_)
|
||||
}
|
||||
|
||||
async fn _handle_stop(&self) {
|
||||
log::warn!("DAG PRUNE TASK STOPPED");
|
||||
async fn _handle_stop(&self, sled_db: sled::Db) {
|
||||
info!(target: "event_graph::_handle_stop()", "[EVENTGRAPH] Prune task stopped, flushing sled");
|
||||
sled_db.flush_async().await.unwrap();
|
||||
}
|
||||
|
||||
/// Generate a deterministic genesis event corresponding to the DAG's configuration.
|
||||
@@ -204,6 +205,7 @@ impl EventGraph {
|
||||
sleep(s).await;
|
||||
debug!(target: "event_graph::dag_prune()", "Rotation period reached. Pruning DAG");
|
||||
|
||||
*self.unreferenced_tips.write().await = HashSet::new();
|
||||
self.dag.clear()?;
|
||||
self.dag_insert(¤t_genesis).await?;
|
||||
debug!(target: "event_graph::dag_prune()", "DAG pruned successfully");
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
*/
|
||||
|
||||
use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
sync::{
|
||||
atomic::{AtomicUsize, Ordering::SeqCst},
|
||||
Arc,
|
||||
|
||||
@@ -114,7 +114,7 @@ async fn eventgraph_propagation_real(ex: Arc<Executor<'static>>) {
|
||||
let p2p = P2p::new(settings, ex.clone()).await;
|
||||
let sled_db = sled::Config::new().temporary(true).open().unwrap();
|
||||
let event_graph =
|
||||
EventGraph::new(p2p.clone(), &sled_db, "dag", 1, ex.clone()).await.unwrap();
|
||||
EventGraph::new(p2p.clone(), sled_db, "dag", 1, ex.clone()).await.unwrap();
|
||||
let event_graph_ = event_graph.clone();
|
||||
|
||||
// Take the last sled item since there's only 1
|
||||
|
||||
Reference in New Issue
Block a user