review fixes

This commit is contained in:
Boog900 2024-09-15 18:38:00 +01:00
parent 0907454e25
commit 47fb1a2d4a
No known key found for this signature in database
GPG key ID: 42AB1287CB0041C2
6 changed files with 13 additions and 6 deletions

View file

@ -32,7 +32,7 @@ pub mod thread;
pub mod time;
#[cfg(feature = "tx-utils")]
pub mod tx_utils;
pub mod tx;
//---------------------------------------------------------------------------------------------------- Private Usage
//----------------------------------------------------------------------------------------------------

View file

@ -9,7 +9,7 @@ use cuprate_database::{
};
use cuprate_helper::{
map::{combine_low_high_bits_to_u128, split_u128_into_low_high_bits},
tx_utils::tx_fee,
tx::tx_fee,
};
use cuprate_types::{
AltBlockInformation, ChainId, ExtendedBlockHeader, HardFork, VerifiedBlockInformation,
@ -156,7 +156,11 @@ pub fn pop_block(
let block = Block::read(&mut block_blob.as_slice())?;
//------------------------------------------------------ Transaction / Outputs / Key Images
let mut txs = Vec::with_capacity(block.transactions.len());
let mut txs = if move_to_alt_chain.is_some() {
Vec::with_capacity(block.transactions.len())
} else {
Vec::new()
};
remove_tx(&block.miner_transaction.hash(), tables)?;
for tx_hash in &block.transactions {

View file

@ -11,7 +11,7 @@ use std::sync::LazyLock;
use hex_literal::hex;
use monero_serai::{block::Block, transaction::Transaction};
use cuprate_helper::{map::combine_low_high_bits_to_u128, tx_utils::tx_fee};
use cuprate_helper::{map::combine_low_high_bits_to_u128, tx::tx_fee};
use cuprate_types::{VerifiedBlockInformation, VerifiedTransactionInformation};
use crate::data::constants::{

View file

@ -8,7 +8,7 @@ use serde::Deserialize;
use serde_json::json;
use tokio::task::spawn_blocking;
use cuprate_helper::tx_utils::tx_fee;
use cuprate_helper::tx::tx_fee;
use cuprate_types::{VerifiedBlockInformation, VerifiedTransactionInformation};
//---------------------------------------------------------------------------------------------------- Constants

View file

@ -2,7 +2,6 @@
//!
//! Tests that assert particular requests lead to particular
//! responses are also tested in Cuprate's blockchain database crate.
//!
//---------------------------------------------------------------------------------------------------- Import
use std::{
collections::{HashMap, HashSet},
@ -114,10 +113,12 @@ pub enum BlockchainWriteRequest {
///
/// Input is an already verified block.
WriteBlock(VerifiedBlockInformation),
/// Write an alternative block to the database,
///
/// Input is the alternative block.
WriteAltBlock(AltBlockInformation),
/// A request to pop some blocks from the top of the main chain
///
/// Input is the amount of blocks to pop.
@ -125,6 +126,7 @@ pub enum BlockchainWriteRequest {
/// This request flushes all alt-chains from the cache before adding the popped blocks to the
/// alt cache.
PopBlocks(usize),
/// A request to reverse the re-org process.
///
/// The inner value is the [`ChainId`] of the old main chain.
@ -132,6 +134,7 @@ pub enum BlockchainWriteRequest {
/// # Invariant
/// It is invalid to call this with a [`ChainId`] that was not returned from [`BlockchainWriteRequest::PopBlocks`].
ReverseReorg(ChainId),
/// A request to flush all alternative blocks.
FlushAltBlocks,
}