mirror of
https://github.com/Cuprate/cuprate.git
synced 2024-12-23 03:59:31 +00:00
manger -> manager
This commit is contained in:
parent
783f4260b4
commit
375a1e1826
3 changed files with 15 additions and 15 deletions
|
@ -1,16 +1,16 @@
|
||||||
//! The blockchain manger interface.
|
//! The blockchain manager interface.
|
||||||
//!
|
//!
|
||||||
//! This module contains all the functions to mutate the blockchain's state in any way, through the
|
//! This module contains all the functions to mutate the blockchain's state in any way, through the
|
||||||
//! blockchain manger.
|
//! blockchain manager.
|
||||||
use monero_serai::{block::Block, transaction::Transaction};
|
|
||||||
use rayon::prelude::*;
|
|
||||||
use std::sync::LazyLock;
|
|
||||||
use std::{
|
use std::{
|
||||||
collections::{HashMap, HashSet},
|
collections::{HashMap, HashSet},
|
||||||
sync::{Mutex, OnceLock},
|
sync::{Mutex, OnceLock, LazyLock},
|
||||||
};
|
};
|
||||||
|
|
||||||
use tokio::sync::{mpsc, oneshot};
|
use tokio::sync::{mpsc, oneshot};
|
||||||
use tower::{Service, ServiceExt};
|
use tower::{Service, ServiceExt};
|
||||||
|
use monero_serai::{block::Block, transaction::Transaction};
|
||||||
|
use rayon::prelude::*;
|
||||||
|
|
||||||
use cuprate_blockchain::service::BlockchainReadHandle;
|
use cuprate_blockchain::service::BlockchainReadHandle;
|
||||||
use cuprate_consensus::transactions::new_tx_verification_data;
|
use cuprate_consensus::transactions::new_tx_verification_data;
|
||||||
|
@ -24,9 +24,9 @@ use crate::{
|
||||||
blockchain::manager::BlockchainManagerCommand, constants::PANIC_CRITICAL_SERVICE_ERROR,
|
blockchain::manager::BlockchainManagerCommand, constants::PANIC_CRITICAL_SERVICE_ERROR,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// The channel used to send [`BlockchainManagerCommand`]s to the blockchain manger.
|
/// The channel used to send [`BlockchainManagerCommand`]s to the blockchain manager.
|
||||||
///
|
///
|
||||||
/// This channel is initialized in [`init_blockchain_manger`](super::manager::init_blockchain_manger).
|
/// This channel is initialized in [`init_blockchain_manager`](super::manager::init_blockchain_manager).
|
||||||
pub(super) static COMMAND_TX: OnceLock<mpsc::Sender<BlockchainManagerCommand>> = OnceLock::new();
|
pub(super) static COMMAND_TX: OnceLock<mpsc::Sender<BlockchainManagerCommand>> = OnceLock::new();
|
||||||
|
|
||||||
/// An error that can be returned from [`handle_incoming_block`].
|
/// An error that can be returned from [`handle_incoming_block`].
|
||||||
|
@ -50,7 +50,7 @@ pub enum IncomingBlockError {
|
||||||
/// This returns a [`bool`] indicating if the block was added to the main-chain ([`true`]) or an alt-chain
|
/// This returns a [`bool`] indicating if the block was added to the main-chain ([`true`]) or an alt-chain
|
||||||
/// ([`false`]).
|
/// ([`false`]).
|
||||||
///
|
///
|
||||||
/// If we already knew about this block or the blockchain manger is not setup yet `Ok(false)` is returned.
|
/// If we already knew about this block or the blockchain manager is not setup yet `Ok(false)` is returned.
|
||||||
///
|
///
|
||||||
/// # Errors
|
/// # Errors
|
||||||
///
|
///
|
||||||
|
@ -110,7 +110,7 @@ pub async fn handle_incoming_block(
|
||||||
.map_err(IncomingBlockError::InvalidBlock)?;
|
.map_err(IncomingBlockError::InvalidBlock)?;
|
||||||
|
|
||||||
let Some(incoming_block_tx) = COMMAND_TX.get() else {
|
let Some(incoming_block_tx) = COMMAND_TX.get() else {
|
||||||
// We could still be starting up the blockchain manger, so just return this as there is nothing
|
// We could still be starting up the blockchain manager, so just return this as there is nothing
|
||||||
// else we can do.
|
// else we can do.
|
||||||
return Ok(false);
|
return Ok(false);
|
||||||
};
|
};
|
||||||
|
|
|
@ -37,11 +37,11 @@ mod handler;
|
||||||
|
|
||||||
pub use commands::BlockchainManagerCommand;
|
pub use commands::BlockchainManagerCommand;
|
||||||
|
|
||||||
/// Initialize the blockchain manger.
|
/// Initialize the blockchain manager.
|
||||||
///
|
///
|
||||||
/// This function sets up the [`BlockchainManager`] and the [`syncer`] so that the functions in [`interface`](super::interface)
|
/// This function sets up the [`BlockchainManager`] and the [`syncer`] so that the functions in [`interface`](super::interface)
|
||||||
/// can be called.
|
/// can be called.
|
||||||
pub async fn init_blockchain_manger(
|
pub async fn init_blockchain_manager(
|
||||||
clearnet_interface: NetworkInterface<ClearNet>,
|
clearnet_interface: NetworkInterface<ClearNet>,
|
||||||
blockchain_write_handle: BlockchainWriteHandle,
|
blockchain_write_handle: BlockchainWriteHandle,
|
||||||
blockchain_read_handle: BlockchainReadHandle,
|
blockchain_read_handle: BlockchainReadHandle,
|
||||||
|
@ -76,7 +76,7 @@ pub async fn init_blockchain_manger(
|
||||||
panic!("Blockchain context service returned wrong response!");
|
panic!("Blockchain context service returned wrong response!");
|
||||||
};
|
};
|
||||||
|
|
||||||
let manger = BlockchainManager {
|
let manager = BlockchainManager {
|
||||||
blockchain_write_handle,
|
blockchain_write_handle,
|
||||||
blockchain_read_handle,
|
blockchain_read_handle,
|
||||||
blockchain_context_service,
|
blockchain_context_service,
|
||||||
|
@ -86,7 +86,7 @@ pub async fn init_blockchain_manger(
|
||||||
broadcast_svc: clearnet_interface.broadcast_svc(),
|
broadcast_svc: clearnet_interface.broadcast_svc(),
|
||||||
};
|
};
|
||||||
|
|
||||||
tokio::spawn(manger.run(batch_rx, command_rx));
|
tokio::spawn(manager.run(batch_rx, command_rx));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The blockchain manager.
|
/// The blockchain manager.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
//! The blockchain manger handler functions.
|
//! The blockchain manager handler functions.
|
||||||
use std::{collections::HashMap, sync::Arc};
|
use std::{collections::HashMap, sync::Arc};
|
||||||
|
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
|
|
Loading…
Reference in a new issue