Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 0 additions & 80 deletions dash-spv/src/chain/fork_detector.rs

This file was deleted.

24 changes: 0 additions & 24 deletions dash-spv/src/chain/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Chain management module with reorganization support
//!
//! This module provides functionality for managing blockchain state including:
//! - Fork detection and handling
//! - Chain reorganization
//! - Multiple chain tip tracking
//! - Chain work calculation
Expand All @@ -11,9 +10,7 @@ pub mod chain_tip;
pub mod chain_work;
pub mod chainlock_manager;
pub mod checkpoints;
pub mod fork_detector;
pub mod orphan_pool;
pub mod reorg;

#[cfg(test)]
mod checkpoint_test;
Expand All @@ -24,25 +21,4 @@ pub use chain_tip::{ChainTip, ChainTipManager};
pub use chain_work::ChainWork;
pub use chainlock_manager::{ChainLockEntry, ChainLockManager, ChainLockStats};
pub use checkpoints::{Checkpoint, CheckpointManager};
pub use fork_detector::{ForkDetectionResult, ForkDetector};
pub use orphan_pool::{OrphanBlock, OrphanPool, OrphanPoolStats};
pub use reorg::ReorgEvent;

use dashcore::{BlockHash, Header as BlockHeader};

/// Represents a potential chain fork
#[derive(Debug, Clone)]
pub struct Fork {
/// The block hash where the fork diverges from the main chain
pub fork_point: BlockHash,
/// The height of the fork point
pub fork_height: u32,
/// The tip of the forked chain
pub tip_hash: BlockHash,
/// The height of the fork tip
pub tip_height: u32,
/// Headers in the fork (from fork point to tip)
pub headers: Vec<BlockHeader>,
/// Cumulative chain work of this fork
pub chain_work: ChainWork,
}
40 changes: 0 additions & 40 deletions dash-spv/src/chain/reorg.rs

This file was deleted.

9 changes: 1 addition & 8 deletions dash-spv/src/sync/headers/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use dashcore::{
use dashcore_hashes::Hash;

use crate::chain::checkpoints::{mainnet_checkpoints, testnet_checkpoints, CheckpointManager};
use crate::chain::{ChainTip, ChainTipManager, ChainWork, ForkDetector};
use crate::chain::{ChainTip, ChainTipManager, ChainWork};
use crate::client::ClientConfig;
use crate::error::{SyncError, SyncResult};
use crate::network::NetworkManager;
Expand Down Expand Up @@ -47,7 +47,6 @@ pub struct HeaderSyncManager<S: StorageManager, N: NetworkManager> {
_phantom_s: std::marker::PhantomData<S>,
_phantom_n: std::marker::PhantomData<N>,
config: ClientConfig,
fork_detector: ForkDetector,
tip_manager: ChainTipManager,
checkpoint_manager: CheckpointManager,
reorg_config: ReorgConfig,
Expand Down Expand Up @@ -83,8 +82,6 @@ impl<S: StorageManager + Send + Sync + 'static, N: NetworkManager + Send + Sync

Ok(Self {
config: config.clone(),
fork_detector: ForkDetector::new(reorg_config.max_forks)
.map_err(|e| SyncError::InvalidState(e.to_string()))?,
tip_manager: ChainTipManager::new(reorg_config.max_forks),
checkpoint_manager,
reorg_config,
Expand Down Expand Up @@ -842,10 +839,6 @@ impl<S: StorageManager + Send + Sync + 'static, N: NetworkManager + Send + Sync
// Reset sync state
self.syncing_headers = false;
self.last_sync_progress = std::time::Instant::now();
// Clear any fork tracking state that shouldn't persist across restarts
self.fork_detector = ForkDetector::new(self.reorg_config.max_forks).map_err(|e| {
SyncError::InvalidState(format!("Failed to create fork detector: {}", e))
})?;
tracing::debug!("Reset header sync pending requests");
Ok(())
}
Expand Down