This commit is contained in:
hinto.janai 2024-09-27 16:58:57 -04:00
parent a5316ad331
commit 7902f0a902
No known key found for this signature in database
GPG key ID: D47CE05FA175A499
5 changed files with 10 additions and 21 deletions

1
Cargo.lock generated
View file

@ -885,7 +885,6 @@ dependencies = [
name = "cuprate-types"
version = "0.0.0"
dependencies = [
"bytemuck",
"bytes",
"cuprate-epee-encoding",
"cuprate-fixed-bytes",

View file

@ -13,9 +13,8 @@ default = ["blockchain", "epee", "serde", "json", "hex"]
blockchain = []
epee = ["dep:cuprate-epee-encoding"]
serde = ["dep:serde"]
bytemuck = ["dep:bytemuck"]
proptest = ["dep:proptest", "dep:proptest-derive"]
json = ["hex", "bytemuck", "dep:cuprate-helper"]
json = ["hex", "dep:cuprate-helper"]
hex = ["dep:hex", "dep:paste"]
[dependencies]
@ -23,7 +22,6 @@ cuprate-epee-encoding = { path = "../net/epee-encoding", optional = true }
cuprate-helper = { path = "../helper", optional = true, features = ["cast"] }
cuprate-fixed-bytes = { path = "../net/fixed-bytes" }
bytemuck = { workspace = true, features = ["derive"], optional = true }
bytes = { workspace = true }
curve25519-dalek = { workspace = true }
monero-serai = { workspace = true }

View file

@ -3,16 +3,6 @@
//! This module provides transparent wrapper types for
//! 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")]
use cuprate_epee_encoding::{error, macros::bytes, EpeeValue, Marker};
#[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.")]
#[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", serde(transparent))]
#[repr(transparent)]

View file

@ -116,12 +116,13 @@ impl TryFrom<transaction::Transaction> for MinerTransaction {
})
.collect();
// TODO: use cuprate_constants target time
let unlock_time = match prefix.additional_timelock {
transaction::Timelock::None => height,
transaction::Timelock::Block(height_lock) => height + usize_to_u64(height_lock),
transaction::Timelock::Time(seconds) => height + (seconds * 120),
} + 60;
transaction::Timelock::Time(seconds) => {
height + (seconds / usize_to_u64(monero_serai::BLOCK_TIME))
}
} + usize_to_u64(monero_serai::DEFAULT_LOCK_WINDOW);
Ok(MinerTransactionPrefix {
version,

View file

@ -105,12 +105,13 @@ impl From<transaction::Transaction> for Transaction {
})
.collect();
// TODO: use cuprate_constants target time
let unlock_time = match prefix.additional_timelock {
transaction::Timelock::None => height,
transaction::Timelock::Block(height_lock) => height + usize_to_u64(height_lock),
transaction::Timelock::Time(seconds) => height + (seconds * 120),
} + 60;
transaction::Timelock::Time(seconds) => {
height + (seconds / usize_to_u64(monero_serai::BLOCK_TIME))
}
} + usize_to_u64(monero_serai::DEFAULT_LOCK_WINDOW);
TransactionPrefix {
version,
@ -121,6 +122,7 @@ impl From<transaction::Transaction> for Transaction {
}
}
#[expect(unreachable_code, unused_variables, reason = "TODO: finish impl")]
match tx {
transaction::Transaction::V1 { prefix, signatures } => Self::V1 {
prefix: map_prefix(prefix, 1),