cuprate/consensus/src/lib.rs

62 lines
1.6 KiB
Rust
Raw Normal View History

pub mod block;
2023-09-03 22:50:38 +00:00
pub mod genesis;
pub mod hardforks;
pub mod miner_tx;
#[cfg(feature = "binaries")]
2023-09-03 22:50:38 +00:00
pub mod rpc;
2023-10-04 13:50:13 +00:00
pub mod verifier;
2023-09-03 22:50:38 +00:00
#[derive(Debug, thiserror::Error)]
pub enum ConsensusError {
2023-09-03 22:50:38 +00:00
#[error("Invalid hard fork version: {0}")]
InvalidHardForkVersion(&'static str),
#[error("Database error: {0}")]
Database(#[from] tower::BoxError),
}
pub trait Database:
tower::Service<DatabaseRequest, Response = DatabaseResponse, Error = tower::BoxError>
{
}
impl<T: tower::Service<DatabaseRequest, Response = DatabaseResponse, Error = tower::BoxError>>
Database for T
{
}
#[derive(Debug, Clone)]
2023-09-03 22:50:38 +00:00
pub enum DatabaseRequest {
BlockHFInfo(cuprate_common::BlockID),
2023-09-06 14:54:49 +00:00
BlockPOWInfo(cuprate_common::BlockID),
BlockWeights(cuprate_common::BlockID),
BlockHfInfoInRange(std::ops::Range<u64>),
BlockWeightsInRange(std::ops::Range<u64>),
BlockPOWInfoInRange(std::ops::Range<u64>),
2023-09-03 22:50:38 +00:00
ChainHeight,
#[cfg(feature = "binaries")]
BlockBatchInRange(std::ops::Range<u64>),
2023-10-04 13:50:13 +00:00
#[cfg(feature = "binaries")]
Transactions(Vec<[u8; 32]>),
2023-09-03 22:50:38 +00:00
}
#[derive(Debug)]
pub enum DatabaseResponse {
BlockHFInfo(hardforks::BlockHFInfo),
BlockPOWInfo(block::pow::BlockPOWInfo),
BlockWeights(block::weight::BlockWeightInfo),
BlockHfInfoInRange(Vec<hardforks::BlockHFInfo>),
BlockWeightsInRange(Vec<block::weight::BlockWeightInfo>),
BlockPOWInfoInRange(Vec<block::pow::BlockPOWInfo>),
2023-09-03 22:50:38 +00:00
ChainHeight(u64),
#[cfg(feature = "binaries")]
BlockBatchInRange(Vec<monero_serai::block::Block>),
2023-10-04 13:50:13 +00:00
#[cfg(feature = "binaries")]
Transactions(Vec<monero_serai::transaction::Transaction>),
2023-09-03 22:50:38 +00:00
}