cuprate_consensus_rules/
lib.rs1cfg_if::cfg_if! {
2 if #[cfg(test)] {
4 use proptest as _;
5 use proptest_derive as _;
6 use tokio as _;
7 }
8}
9
10use std::time::{SystemTime, UNIX_EPOCH};
11
12pub mod batch_verifier;
13pub mod blocks;
14mod decomposed_amount;
15pub mod genesis;
16pub mod hard_forks;
17pub mod miner_tx;
18pub mod transactions;
19
20pub use decomposed_amount::is_decomposed_amount;
21pub use hard_forks::{check_block_version_vote, HFVotes, HFsInfo, HardFork};
22pub use transactions::TxVersion;
23
24#[derive(Debug, Clone, Copy, PartialEq, Eq, thiserror::Error)]
25pub enum ConsensusError {
26 #[error("Block error: {0}")]
27 Block(#[from] blocks::BlockError),
28 #[error("Transaction error: {0}")]
29 Transaction(#[from] transactions::TransactionError),
30}
31
32pub fn current_unix_timestamp() -> u64 {
34 SystemTime::now()
35 .duration_since(UNIX_EPOCH)
36 .unwrap()
37 .as_secs()
38}
39
40#[cfg(feature = "rayon")]
43fn try_par_iter<T>(t: T) -> T::Iter
44where
45 T: rayon::iter::IntoParallelIterator,
46{
47 t.into_par_iter()
48}
49
50#[cfg(not(feature = "rayon"))]
53fn try_par_iter<T>(t: T) -> impl Iterator<Item = T::Item>
54where
55 T: IntoIterator,
56{
57 t.into_iter()
58}