cuprate/consensus/src/lib.rs

51 lines
1.3 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;
2023-09-03 22:50:38 +00:00
#[cfg(feature = "rpc")]
pub mod rpc;
#[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,
}
#[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),
}