Skip to content

Commit

Permalink
data inconsistent will be ignore when adding dag into reachability data
Browse files Browse the repository at this point in the history
  • Loading branch information
jackzhhuang committed Dec 14, 2024
1 parent 5092772 commit 78ad69e
Showing 1 changed file with 33 additions and 6 deletions.
39 changes: 33 additions & 6 deletions flexidag/src/blockdag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use crate::consensusdb::{
use crate::ghostdag::protocol::GhostdagManager;
use crate::process_key_already_error;
use crate::prune::pruning_point_manager::PruningPointManagerT;
use crate::reachability::ReachabilityError;
use anyhow::{bail, ensure, Ok};
use rocksdb::WriteBatch;
use starcoin_config::temp_dir;
Expand Down Expand Up @@ -242,13 +243,26 @@ impl BlockDAG {
.filter(|hash| self.storage.reachability_store.read().has(*hash).unwrap())
.collect::<Vec<_>>()
.into_iter();
inquirer::add_block(
match inquirer::add_block(
&mut stage,
header.id(),
ghostdata.selected_parent,
&mut merge_set,
)
.expect("failed to add reachability in stage batch");
) {
std::result::Result::Ok(_) => {}
Err(e) => match e {
ReachabilityError::DataInconsistency => {
info!(
"the key {:?} was already processed, original error message: {:?}",
header.id(),
ReachabilityError::DataInconsistency
);
}
_ => {
panic!("failed to add block in batch for error: {:?}", e);
}
},
}

process_key_already_error(self.storage.relations_store.write().insert_batch(
&mut batch,
Expand Down Expand Up @@ -339,13 +353,26 @@ impl BlockDAG {
.collect::<Vec<_>>()
.into_iter();

inquirer::add_block(
match inquirer::add_block(
&mut stage,
header.id(),
ghostdata.selected_parent,
&mut merge_set,
)
.expect("failed to add block in batch");
) {
std::result::Result::Ok(_) => {}
Err(e) => match e {
ReachabilityError::DataInconsistency => {
info!(
"the key {:?} was already processed, original error message: {:?}",
header.id(),
ReachabilityError::DataInconsistency
);
}
_ => {
panic!("failed to add block in batch for error: {:?}", e);
}
},
}

process_key_already_error(self.storage.relations_store.write().insert_batch(
&mut batch,
Expand Down

0 comments on commit 78ad69e

Please sign in to comment.