mirror of
https://github.com/hinto-janai/cuprate.git
synced 2025-02-04 12:16:36 +00:00
features
This commit is contained in:
parent
4f87767063
commit
374bc77cfb
8 changed files with 39 additions and 11 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -603,6 +603,7 @@ dependencies = [
|
||||||
name = "cuprate-constants"
|
name = "cuprate-constants"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
"hex",
|
"hex",
|
||||||
"hex-literal",
|
"hex-literal",
|
||||||
"monero-serai",
|
"monero-serai",
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
use monero_serai::transaction::{Input, Output, Timelock, Transaction};
|
use monero_serai::transaction::{Input, Output, Timelock, Transaction};
|
||||||
|
|
||||||
use cuprate_constants::block::MAX_BLOCK_HEIGHT;
|
use cuprate_constants::block::MAX_BLOCK_HEIGHT_USIZE;
|
||||||
use cuprate_helper::cast::u64_to_usize;
|
|
||||||
use cuprate_types::TxVersion;
|
use cuprate_types::TxVersion;
|
||||||
|
|
||||||
use crate::{is_decomposed_amount, transactions::check_output_types, HardFork};
|
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) => {
|
&Timelock::Block(till_height) => {
|
||||||
// Lock times above this amount are timestamps not blocks.
|
// Lock times above this amount are timestamps not blocks.
|
||||||
// This is just for safety though and shouldn't actually be hit.
|
// 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)?;
|
Err(MinerTxError::InvalidLockTime)?;
|
||||||
}
|
}
|
||||||
if till_height != chain_height + MINER_TX_TIME_LOCKED_BLOCKS {
|
if till_height != chain_height + MINER_TX_TIME_LOCKED_BLOCKS {
|
||||||
|
|
|
@ -9,13 +9,17 @@ repository = "https://github.com/Cuprate/cuprate/tree/main/constants"
|
||||||
keywords = ["cuprate", "constants"]
|
keywords = ["cuprate", "constants"]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["monero-serai"]
|
default = []
|
||||||
monero-serai = ["dep:monero-serai"]
|
block = []
|
||||||
|
build = []
|
||||||
|
genesis = ["dep:monero-serai", "dep:hex-literal", "dep:paste"]
|
||||||
|
rpc = []
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
cfg-if = { workspace = true }
|
||||||
monero-serai = { workspace = true, optional = true }
|
monero-serai = { workspace = true, optional = true }
|
||||||
hex-literal = { workspace = true }
|
hex-literal = { workspace = true, optional = true }
|
||||||
paste = { workspace = true }
|
paste = { workspace = true, optional = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
monero-serai = { workspace = true }
|
monero-serai = { workspace = true }
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# cuprate-constants
|
# cuprate-constants
|
||||||
This crate contains general constants that are not specific to any particular
|
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
|
## 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.
|
|
@ -1,9 +1,22 @@
|
||||||
#![doc = include_str!("../README.md")]
|
#![doc = include_str!("../README.md")]
|
||||||
#![deny(missing_docs, reason = "all constants should document what they are")]
|
#![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;
|
mod macros;
|
||||||
|
|
||||||
|
#[cfg(feature = "block")]
|
||||||
pub mod block;
|
pub mod block;
|
||||||
|
#[cfg(feature = "build")]
|
||||||
pub mod build;
|
pub mod build;
|
||||||
|
#[cfg(feature = "genesis")]
|
||||||
pub mod genesis;
|
pub mod genesis;
|
||||||
|
#[cfg(feature = "rpc")]
|
||||||
pub mod rpc;
|
pub mod rpc;
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
/// Output a string link to `monerod` source code.
|
/// 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 {
|
macro_rules! monero_definition_link {
|
||||||
(
|
(
|
||||||
$commit:ident, // Git commit hash
|
$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;
|
pub(crate) use monero_definition_link;
|
||||||
|
|
|
@ -24,7 +24,7 @@ thread = ["std", "dep:target_os_lib"]
|
||||||
tx = ["dep:monero-serai"]
|
tx = ["dep:monero-serai"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
cuprate-constants = { path = "../constants", optional = true }
|
cuprate-constants = { path = "../constants", optional = true, features = ["block"] }
|
||||||
|
|
||||||
crossbeam = { workspace = true, optional = true }
|
crossbeam = { workspace = true, optional = true }
|
||||||
chrono = { workspace = true, optional = true, features = ["std", "clock"] }
|
chrono = { workspace = true, optional = true, features = ["std", "clock"] }
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//! Contains [`BlockCompleteEntry`] and the related types.
|
//! Contains [`BlockCompleteEntry`] and the related types.
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- Import
|
//---------------------------------------------------------------------------------------------------- Import
|
||||||
// #[cfg(feature = "epee")]
|
#[cfg(feature = "epee")]
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
|
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
|
|
Loading…
Reference in a new issue