Skip to content

Commit

Permalink
daemon: update is_sync_block function
Browse files Browse the repository at this point in the history
  • Loading branch information
Slixe committed Jan 31, 2024
1 parent 1c13a5d commit abf2d70
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions xelis_daemon/src/core/blockchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -607,9 +607,13 @@ impl<S: Storage> Blockchain<S> {
let sync_block_cumulative_difficulty = storage.get_cumulative_difficulty_for_block_hash(hash).await?;
// if potential sync block has lower cumulative difficulty than one of past blocks, it is not a sync block
for hash in pre_blocks {
let cumulative_difficulty = storage.get_cumulative_difficulty_for_block_hash(&hash).await?;
if cumulative_difficulty >= sync_block_cumulative_difficulty {
return Ok(false)
// We compare only against block ordered otherwise we can have desync between node which could lead to fork
// This is rare event but can happen
if storage.is_block_topological_ordered(&hash).await {
let cumulative_difficulty = storage.get_cumulative_difficulty_for_block_hash(&hash).await?;
if cumulative_difficulty >= sync_block_cumulative_difficulty {
return Ok(false)
}
}
}

Expand Down

0 comments on commit abf2d70

Please sign in to comment.