features
Some checks are pending
Audit / audit (push) Waiting to run
Deny / audit (push) Waiting to run

This commit is contained in:
hinto.janai 2024-09-20 17:39:20 -04:00
parent 4f87767063
commit 374bc77cfb
No known key found for this signature in database
GPG key ID: D47CE05FA175A499
8 changed files with 39 additions and 11 deletions

1
Cargo.lock generated
View file

@ -603,6 +603,7 @@ dependencies = [
name = "cuprate-constants"
version = "0.1.0"
dependencies = [
"cfg-if",
"hex",
"hex-literal",
"monero-serai",

View file

@ -1,7 +1,6 @@
use monero_serai::transaction::{Input, Output, Timelock, Transaction};
use cuprate_constants::block::MAX_BLOCK_HEIGHT;
use cuprate_helper::cast::u64_to_usize;
use cuprate_constants::block::MAX_BLOCK_HEIGHT_USIZE;
use cuprate_types::TxVersion;
use crate::{is_decomposed_amount, transactions::check_output_types, HardFork};
@ -114,7 +113,7 @@ fn check_time_lock(time_lock: &Timelock, chain_height: usize) -> Result<(), Mine
&Timelock::Block(till_height) => {
// Lock times above this amount are timestamps not blocks.
// This is just for safety though and shouldn't actually be hit.
if till_height > u64_to_usize(MAX_BLOCK_HEIGHT) {
if till_height > MAX_BLOCK_HEIGHT_USIZE {
Err(MinerTxError::InvalidLockTime)?;
}
if till_height != chain_height + MINER_TX_TIME_LOCKED_BLOCKS {

View file

@ -9,13 +9,17 @@ repository = "https://github.com/Cuprate/cuprate/tree/main/constants"
keywords = ["cuprate", "constants"]
[features]
default = ["monero-serai"]
monero-serai = ["dep:monero-serai"]
default = []
block = []
build = []
genesis = ["dep:monero-serai", "dep:hex-literal", "dep:paste"]
rpc = []
[dependencies]
cfg-if = { workspace = true }
monero-serai = { workspace = true, optional = true }
hex-literal = { workspace = true }
paste = { workspace = true }
hex-literal = { workspace = true, optional = true }
paste = { workspace = true, optional = true }
[dev-dependencies]
monero-serai = { workspace = true }

View file

@ -1,6 +1,6 @@
# cuprate-constants
This crate contains general constants that are not specific to any particular
part of the codebase yet are used in multiple places such as the [`crate::block::MAX_BLOCK_HEIGHT`].
part of the codebase yet are used in multiple places such as the maximum block height.
## Static data
This crate also contains `static` data used in multiple places such as the [`crate::genesis::mainnet::GENESIS_BLOCK`].
This crate also contains `static` data used in multiple places such as the genesis block.

View file

@ -1,9 +1,22 @@
#![doc = include_str!("../README.md")]
#![deny(missing_docs, reason = "all constants should document what they are")]
cfg_if::cfg_if! {
// Used in test modules.
if #[cfg(test)] {
use hex as _;
use monero_serai as _;
use pretty_assertions as _;
}
}
mod macros;
#[cfg(feature = "block")]
pub mod block;
#[cfg(feature = "build")]
pub mod build;
#[cfg(feature = "genesis")]
pub mod genesis;
#[cfg(feature = "rpc")]
pub mod rpc;

View file

@ -1,4 +1,9 @@
/// Output a string link to `monerod` source code.
#[allow(
clippy::allow_attributes,
unused_macros,
reason = "used in feature gated modules"
)]
macro_rules! monero_definition_link {
(
$commit:ident, // Git commit hash
@ -21,4 +26,10 @@ macro_rules! monero_definition_link {
)
};
}
#[allow(
clippy::allow_attributes,
unused_imports,
reason = "used in feature gated modules"
)]
pub(crate) use monero_definition_link;

View file

@ -24,7 +24,7 @@ thread = ["std", "dep:target_os_lib"]
tx = ["dep:monero-serai"]
[dependencies]
cuprate-constants = { path = "../constants", optional = true }
cuprate-constants = { path = "../constants", optional = true, features = ["block"] }
crossbeam = { workspace = true, optional = true }
chrono = { workspace = true, optional = true, features = ["std", "clock"] }

View file

@ -1,7 +1,7 @@
//! Contains [`BlockCompleteEntry`] and the related types.
//---------------------------------------------------------------------------------------------------- Import
// #[cfg(feature = "epee")]
#[cfg(feature = "epee")]
use bytes::Bytes;
#[cfg(feature = "serde")]