mirror of
https://github.com/hinto-janai/cuprate.git
synced 2025-01-24 11:26:03 +00:00
cleanup
This commit is contained in:
parent
a5316ad331
commit
7902f0a902
5 changed files with 10 additions and 21 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -885,7 +885,6 @@ dependencies = [
|
||||||
name = "cuprate-types"
|
name = "cuprate-types"
|
||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytemuck",
|
|
||||||
"bytes",
|
"bytes",
|
||||||
"cuprate-epee-encoding",
|
"cuprate-epee-encoding",
|
||||||
"cuprate-fixed-bytes",
|
"cuprate-fixed-bytes",
|
||||||
|
|
|
@ -13,9 +13,8 @@ default = ["blockchain", "epee", "serde", "json", "hex"]
|
||||||
blockchain = []
|
blockchain = []
|
||||||
epee = ["dep:cuprate-epee-encoding"]
|
epee = ["dep:cuprate-epee-encoding"]
|
||||||
serde = ["dep:serde"]
|
serde = ["dep:serde"]
|
||||||
bytemuck = ["dep:bytemuck"]
|
|
||||||
proptest = ["dep:proptest", "dep:proptest-derive"]
|
proptest = ["dep:proptest", "dep:proptest-derive"]
|
||||||
json = ["hex", "bytemuck", "dep:cuprate-helper"]
|
json = ["hex", "dep:cuprate-helper"]
|
||||||
hex = ["dep:hex", "dep:paste"]
|
hex = ["dep:hex", "dep:paste"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
@ -23,7 +22,6 @@ cuprate-epee-encoding = { path = "../net/epee-encoding", optional = true }
|
||||||
cuprate-helper = { path = "../helper", optional = true, features = ["cast"] }
|
cuprate-helper = { path = "../helper", optional = true, features = ["cast"] }
|
||||||
cuprate-fixed-bytes = { path = "../net/fixed-bytes" }
|
cuprate-fixed-bytes = { path = "../net/fixed-bytes" }
|
||||||
|
|
||||||
bytemuck = { workspace = true, features = ["derive"], optional = true }
|
|
||||||
bytes = { workspace = true }
|
bytes = { workspace = true }
|
||||||
curve25519-dalek = { workspace = true }
|
curve25519-dalek = { workspace = true }
|
||||||
monero-serai = { workspace = true }
|
monero-serai = { workspace = true }
|
||||||
|
|
|
@ -3,16 +3,6 @@
|
||||||
//! This module provides transparent wrapper types for
|
//! This module provides transparent wrapper types for
|
||||||
//! arrays that (de)serialize from hexadecimal input/output.
|
//! arrays that (de)serialize from hexadecimal input/output.
|
||||||
|
|
||||||
#![cfg_attr(
|
|
||||||
feature = "bytemuck",
|
|
||||||
expect(
|
|
||||||
clippy::allow_attributes,
|
|
||||||
reason = "bytemuck uses allow in its derive macros"
|
|
||||||
)
|
|
||||||
)]
|
|
||||||
|
|
||||||
#[cfg(feature = "bytemuck")]
|
|
||||||
use bytemuck::{Pod, TransparentWrapper, Zeroable};
|
|
||||||
#[cfg(feature = "epee")]
|
#[cfg(feature = "epee")]
|
||||||
use cuprate_epee_encoding::{error, macros::bytes, EpeeValue, Marker};
|
use cuprate_epee_encoding::{error, macros::bytes, EpeeValue, Marker};
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
|
@ -29,7 +19,6 @@ macro_rules! generate_hex_array {
|
||||||
$(
|
$(
|
||||||
#[doc = concat!("Wrapper type that (de)serializes from/to a ", stringify!($array_len), "-byte array.")]
|
#[doc = concat!("Wrapper type that (de)serializes from/to a ", stringify!($array_len), "-byte array.")]
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
#[cfg_attr(feature = "bytemuck", derive(Pod, Zeroable, TransparentWrapper))]
|
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
#[cfg_attr(feature = "serde", serde(transparent))]
|
#[cfg_attr(feature = "serde", serde(transparent))]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
|
|
|
@ -116,12 +116,13 @@ impl TryFrom<transaction::Transaction> for MinerTransaction {
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
// TODO: use cuprate_constants target time
|
|
||||||
let unlock_time = match prefix.additional_timelock {
|
let unlock_time = match prefix.additional_timelock {
|
||||||
transaction::Timelock::None => height,
|
transaction::Timelock::None => height,
|
||||||
transaction::Timelock::Block(height_lock) => height + usize_to_u64(height_lock),
|
transaction::Timelock::Block(height_lock) => height + usize_to_u64(height_lock),
|
||||||
transaction::Timelock::Time(seconds) => height + (seconds * 120),
|
transaction::Timelock::Time(seconds) => {
|
||||||
} + 60;
|
height + (seconds / usize_to_u64(monero_serai::BLOCK_TIME))
|
||||||
|
}
|
||||||
|
} + usize_to_u64(monero_serai::DEFAULT_LOCK_WINDOW);
|
||||||
|
|
||||||
Ok(MinerTransactionPrefix {
|
Ok(MinerTransactionPrefix {
|
||||||
version,
|
version,
|
||||||
|
|
|
@ -105,12 +105,13 @@ impl From<transaction::Transaction> for Transaction {
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
// TODO: use cuprate_constants target time
|
|
||||||
let unlock_time = match prefix.additional_timelock {
|
let unlock_time = match prefix.additional_timelock {
|
||||||
transaction::Timelock::None => height,
|
transaction::Timelock::None => height,
|
||||||
transaction::Timelock::Block(height_lock) => height + usize_to_u64(height_lock),
|
transaction::Timelock::Block(height_lock) => height + usize_to_u64(height_lock),
|
||||||
transaction::Timelock::Time(seconds) => height + (seconds * 120),
|
transaction::Timelock::Time(seconds) => {
|
||||||
} + 60;
|
height + (seconds / usize_to_u64(monero_serai::BLOCK_TIME))
|
||||||
|
}
|
||||||
|
} + usize_to_u64(monero_serai::DEFAULT_LOCK_WINDOW);
|
||||||
|
|
||||||
TransactionPrefix {
|
TransactionPrefix {
|
||||||
version,
|
version,
|
||||||
|
@ -121,6 +122,7 @@ impl From<transaction::Transaction> for Transaction {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[expect(unreachable_code, unused_variables, reason = "TODO: finish impl")]
|
||||||
match tx {
|
match tx {
|
||||||
transaction::Transaction::V1 { prefix, signatures } => Self::V1 {
|
transaction::Transaction::V1 { prefix, signatures } => Self::V1 {
|
||||||
prefix: map_prefix(prefix, 1),
|
prefix: map_prefix(prefix, 1),
|
||||||
|
|
Loading…
Reference in a new issue