mirror of
https://github.com/Cuprate/cuprate.git
synced 2025-03-12 09:29:11 +00:00
Apply suggestions from code review
Co-authored-by: hinto-janai <hinto.janai@protonmail.com>
This commit is contained in:
parent
fb592e3cda
commit
6aeb720dcd
6 changed files with 48 additions and 8 deletions
|
@ -21,7 +21,7 @@ num = []
|
||||||
map = ["cast", "dep:monero-serai"]
|
map = ["cast", "dep:monero-serai"]
|
||||||
time = ["dep:chrono", "std"]
|
time = ["dep:chrono", "std"]
|
||||||
thread = ["std", "dep:target_os_lib"]
|
thread = ["std", "dep:target_os_lib"]
|
||||||
tx-utils = ["dep:monero-serai"]
|
tx = ["dep:monero-serai"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
crossbeam = { workspace = true, optional = true }
|
crossbeam = { workspace = true, optional = true }
|
||||||
|
|
|
@ -31,7 +31,7 @@ pub mod thread;
|
||||||
#[cfg(feature = "time")]
|
#[cfg(feature = "time")]
|
||||||
pub mod time;
|
pub mod time;
|
||||||
|
|
||||||
#[cfg(feature = "tx-utils")]
|
#[cfg(feature = "tx")]
|
||||||
pub mod tx;
|
pub mod tx;
|
||||||
//---------------------------------------------------------------------------------------------------- Private Usage
|
//---------------------------------------------------------------------------------------------------- Private Usage
|
||||||
|
|
||||||
|
|
|
@ -32,3 +32,39 @@ pub fn tx_fee(tx: &Transaction) -> u64 {
|
||||||
|
|
||||||
fee
|
fee
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod test {
|
||||||
|
use curve25519_dalek::{edwards::CompressedEdwardsY, EdwardsPoint};
|
||||||
|
use monero_serai::transaction::{NotPruned, Output, Timelock, TransactionPrefix};
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
#[should_panic(expected = "called `Option::unwrap()` on a `None` value")]
|
||||||
|
fn tx_fee_panic() {
|
||||||
|
let input = Input::ToKey {
|
||||||
|
amount: Some(u64::MAX),
|
||||||
|
key_offsets: vec![],
|
||||||
|
key_image: EdwardsPoint::default(),
|
||||||
|
};
|
||||||
|
|
||||||
|
let output = Output {
|
||||||
|
amount: Some(u64::MAX),
|
||||||
|
key: CompressedEdwardsY::default(),
|
||||||
|
view_tag: None,
|
||||||
|
};
|
||||||
|
|
||||||
|
let tx = Transaction::<NotPruned>::V1 {
|
||||||
|
prefix: TransactionPrefix {
|
||||||
|
additional_timelock: Timelock::None,
|
||||||
|
inputs: vec![input; 2],
|
||||||
|
outputs: vec![output],
|
||||||
|
extra: vec![],
|
||||||
|
},
|
||||||
|
signatures: vec![],
|
||||||
|
};
|
||||||
|
|
||||||
|
tx_fee(&tx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -46,14 +46,16 @@
|
||||||
//!
|
//!
|
||||||
//! Although that would be easier, it makes getting a range of block extremely slow, as we have to build the weight cache to verify
|
//! Although that would be easier, it makes getting a range of block extremely slow, as we have to build the weight cache to verify
|
||||||
//! blocks, roughly 100,000 block headers needed, this cost is too high.
|
//! blocks, roughly 100,000 block headers needed, this cost is too high.
|
||||||
pub use block::*;
|
|
||||||
pub use chain::*;
|
|
||||||
pub use tx::*;
|
|
||||||
|
|
||||||
mod block;
|
mod block;
|
||||||
mod chain;
|
mod chain;
|
||||||
mod tx;
|
mod tx;
|
||||||
|
|
||||||
|
pub use block::{
|
||||||
|
add_alt_block, get_alt_block, get_alt_block_extended_header_from_height, get_alt_block_hash,
|
||||||
|
};
|
||||||
|
pub use chain::{get_alt_chain_history_ranges, update_alt_chain_info};
|
||||||
|
pub use tx::{add_alt_transaction_blob, get_alt_transaction};
|
||||||
|
|
||||||
/// Flush all alt-block data from all the alt-block tables.
|
/// Flush all alt-block data from all the alt-block tables.
|
||||||
///
|
///
|
||||||
/// This function completely empties the alt block tables.
|
/// This function completely empties the alt block tables.
|
||||||
|
|
|
@ -40,7 +40,9 @@ pub fn add_alt_transaction_blob(
|
||||||
|
|
||||||
tables
|
tables
|
||||||
.alt_transaction_blobs_mut()
|
.alt_transaction_blobs_mut()
|
||||||
.put(&tx.tx_hash, StorableVec::wrap_ref(&tx.tx_blob))
|
.put(&tx.tx_hash, StorableVec::wrap_ref(&tx.tx_blob))?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Retrieve a [`VerifiedTransactionInformation`] from the database.
|
/// Retrieve a [`VerifiedTransactionInformation`] from the database.
|
||||||
|
|
|
@ -7,7 +7,7 @@ authors = ["Boog900", "hinto-janai"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
cuprate-types = { path = "../types" }
|
cuprate-types = { path = "../types" }
|
||||||
cuprate-helper = { path = "../helper", features = ["map", "tx-utils"] }
|
cuprate-helper = { path = "../helper", features = ["map", "tx"] }
|
||||||
cuprate-wire = { path = "../net/wire" }
|
cuprate-wire = { path = "../net/wire" }
|
||||||
cuprate-p2p-core = { path = "../p2p/p2p-core", features = ["borsh"] }
|
cuprate-p2p-core = { path = "../p2p/p2p-core", features = ["borsh"] }
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue