Skip to content

Commit 71b6dcc

Browse files
committed
replace SyncState with Syncer/SyncerHandle, add target_height to SyncerHandle, doc nits
1 parent 90bb7fb commit 71b6dcc

7 files changed

Lines changed: 205 additions & 172 deletions

File tree

binaries/cuprated/src/blockchain.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ mod types;
2929
pub use fast_sync::get_fast_sync_hashes;
3030
pub use interface::BlockchainManagerHandle;
3131
pub use manager::init_blockchain_manager;
32-
pub use syncer::SyncState;
32+
pub use syncer::{Syncer, SyncerHandle};
3333
pub use types::ConsensusBlockchainReadHandle;
3434

3535
/// Checks if the genesis block is in the blockchain and adds it if not.

binaries/cuprated/src/blockchain/manager.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,18 @@ mod handler;
3535
mod tests;
3636

3737
pub use commands::{BlockchainManagerCommand, IncomingBlockOk};
38-
use syncer::SyncerHandle;
38+
use syncer::Syncer;
3939

4040
/// Initialize the blockchain manager.
4141
///
42-
/// This function sets up the `BlockchainManager` and the `syncer` so that the functions in [`interface`](super::interface)
42+
/// This function sets up the `BlockchainManager` and the [`Syncer`](syncer::Syncer) so that the functions in [`interface`](super::interface)
4343
/// can be called.
4444
pub async fn init_blockchain_manager(
4545
clearnet_interface: NetworkInterface<ClearNet>,
4646
blockchain_write_handle: BlockchainWriteHandle,
4747
txpool_manager_handle: TxpoolManagerHandle,
4848
block_downloader_config: BlockDownloaderConfig,
49-
syncer_handle: SyncerHandle,
49+
syncer: Syncer,
5050
command_rx: mpsc::Receiver<BlockchainManagerCommand>,
5151
node_ctx: crate::NodeContext,
5252
) {
@@ -59,14 +59,13 @@ pub async fn init_blockchain_manager(
5959
fast_sync_hashes: node_ctx.fast_sync_hashes,
6060
};
6161

62-
tokio::spawn(syncer::syncer(
62+
tokio::spawn(syncer.run(
6363
node_ctx.blockchain_context.clone(),
6464
chain_service,
6565
clearnet_interface.clone(),
6666
batch_tx,
6767
Arc::clone(&stop_current_block_downloader),
6868
block_downloader_config,
69-
syncer_handle,
7069
));
7170

7271
let manager = BlockchainManager {
@@ -103,7 +102,7 @@ pub struct BlockchainManager {
103102
/// The blockchain context cache, this caches the current state of the blockchain to quickly calculate/retrieve
104103
/// values without needing to go to a [`BlockchainReadHandle`].
105104
blockchain_context_service: BlockchainContextService,
106-
/// A [`Notify`] to tell the [`syncer`](syncer::syncer) that we want to cancel this current download
105+
/// A [`Notify`] to tell the [`Syncer`](syncer::Syncer) that we want to cancel this current download
107106
/// attempt.
108107
stop_current_block_downloader: Arc<Notify>,
109108
/// The broadcast service, to broadcast new blocks.

0 commit comments

Comments
 (0)