2023-09-28 11:21:06 +00:00
|
|
|
pub mod block;
|
2023-09-03 22:50:38 +00:00
|
|
|
pub mod genesis;
|
|
|
|
pub mod hardforks;
|
2023-09-28 11:21:06 +00:00
|
|
|
pub mod miner_tx;
|
2023-10-03 21:10:31 +00:00
|
|
|
#[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)]
|
2023-10-02 20:07:11 +00:00
|
|
|
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
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2023-09-05 18:13:46 +00:00
|
|
|
#[derive(Debug, Clone)]
|
2023-09-03 22:50:38 +00:00
|
|
|
pub enum DatabaseRequest {
|
2023-10-02 20:07:11 +00:00
|
|
|
BlockHFInfo(cuprate_common::BlockID),
|
2023-09-06 14:54:49 +00:00
|
|
|
BlockPOWInfo(cuprate_common::BlockID),
|
2023-09-28 11:21:06 +00:00
|
|
|
BlockWeights(cuprate_common::BlockID),
|
|
|
|
|
2023-10-02 20:07:11 +00:00
|
|
|
BlockHfInfoInRange(std::ops::Range<u64>),
|
2023-09-28 11:21:06 +00:00
|
|
|
BlockWeightsInRange(std::ops::Range<u64>),
|
2023-10-02 20:07:11 +00:00
|
|
|
BlockPOWInfoInRange(std::ops::Range<u64>),
|
2023-09-28 11:21:06 +00:00
|
|
|
|
2023-09-03 22:50:38 +00:00
|
|
|
ChainHeight,
|
2023-10-03 21:10:31 +00:00
|
|
|
|
|
|
|
#[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 {
|
2023-10-03 21:10:31 +00:00
|
|
|
BlockHFInfo(hardforks::BlockHFInfo),
|
2023-09-28 11:21:06 +00:00
|
|
|
BlockPOWInfo(block::pow::BlockPOWInfo),
|
|
|
|
BlockWeights(block::weight::BlockWeightInfo),
|
|
|
|
|
2023-10-02 20:07:11 +00:00
|
|
|
BlockHfInfoInRange(Vec<hardforks::BlockHFInfo>),
|
2023-09-28 11:21:06 +00:00
|
|
|
BlockWeightsInRange(Vec<block::weight::BlockWeightInfo>),
|
2023-10-02 20:07:11 +00:00
|
|
|
BlockPOWInfoInRange(Vec<block::pow::BlockPOWInfo>),
|
2023-09-28 11:21:06 +00:00
|
|
|
|
2023-09-03 22:50:38 +00:00
|
|
|
ChainHeight(u64),
|
2023-10-03 21:10:31 +00:00
|
|
|
|
|
|
|
#[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
|
|
|
}
|