remove blockchain height from txpool
Some checks failed
Audit / audit (push) Has been cancelled
Deny / audit (push) Has been cancelled

This commit is contained in:
Boog900 2024-10-14 20:24:12 +01:00
parent bfb4cbf831
commit 6c1f871d81
No known key found for this signature in database
GPG key ID: 42AB1287CB0041C2
5 changed files with 5 additions and 43 deletions

View file

@ -447,7 +447,6 @@ impl super::BlockchainManager {
})
})
.collect::<Vec<[u8; 32]>>();
let blockchain_height = verified_block.height + 1;
self.blockchain_context_service
.ready()
@ -492,10 +491,7 @@ impl super::BlockchainManager {
.ready()
.await
.expect(PANIC_CRITICAL_SERVICE_ERROR)
.call(TxpoolWriteRequest::NewBlock {
spent_key_images,
blockchain_height,
})
.call(TxpoolWriteRequest::NewBlock { spent_key_images })
.await
.expect(PANIC_CRITICAL_SERVICE_ERROR);
}

View file

@ -106,8 +106,6 @@ pub enum TxpoolWriteRequest {
/// Tell the tx-pool about a new block.
NewBlock {
/// The new blockchain height.
blockchain_height: usize,
/// The spent key images in the new block.
spent_key_images: Vec<KeyImage>,
},

View file

@ -10,8 +10,8 @@ use crate::{
interface::{TxpoolWriteRequest, TxpoolWriteResponse},
types::TxpoolWriteHandle,
},
tables::{OpenTables, Tables, TablesMut, TransactionInfos},
types::{KeyImage, PoolInfo, TransactionHash, TxStateFlags},
tables::{OpenTables, Tables, TransactionInfos},
types::{KeyImage, TransactionHash, TxStateFlags},
};
//---------------------------------------------------------------------------------------------------- init_write_service
@ -32,10 +32,7 @@ fn handle_txpool_request(
}
TxpoolWriteRequest::RemoveTransaction(tx_hash) => remove_transaction(env, tx_hash),
TxpoolWriteRequest::Promote(tx_hash) => promote(env, tx_hash),
TxpoolWriteRequest::NewBlock {
blockchain_height,
spent_key_images,
} => new_block(env, *blockchain_height, spent_key_images),
TxpoolWriteRequest::NewBlock { spent_key_images } => new_block(env, spent_key_images),
}
}
@ -130,7 +127,6 @@ fn promote(
fn new_block(
env: &ConcreteEnv,
blockchain_height: usize,
spent_key_images: &[KeyImage],
) -> Result<TxpoolWriteResponse, RuntimeError> {
let env_inner = env.env_inner();
@ -151,23 +147,6 @@ fn new_block(
}
}
let res = tables_mut.pool_stats_mut().update(&(), |mut info| {
info.last_known_blockchain_height = blockchain_height;
Some(info)
});
match res {
Ok(()) => (),
Err(RuntimeError::KeyNotFound) => tables_mut.pool_stats_mut().put(
&(),
&PoolInfo {
last_known_blockchain_height: blockchain_height,
},
)?,
Err(e) => return Err(e),
}
Ok(())
};

View file

@ -17,8 +17,7 @@
use cuprate_database::{define_tables, StorableVec};
use crate::types::{
KeyImage, PoolInfo, RawCachedVerificationState, TransactionBlobHash, TransactionHash,
TransactionInfo,
KeyImage, RawCachedVerificationState, TransactionBlobHash, TransactionHash, TransactionInfo,
};
define_tables! {
@ -49,7 +48,4 @@ define_tables! {
/// Transaction blob hashes that are in the pool.
4 => KnownBlobHashes,
TransactionBlobHash => TransactionHash,
5 => PoolStats,
() => PoolInfo,
}

View file

@ -19,13 +19,6 @@ pub type TransactionHash = [u8; 32];
/// A transaction blob hash.
pub type TransactionBlobHash = [u8; 32];
/// Information on the tx-pool.
#[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Eq, Ord, Hash, Pod, Zeroable)]
#[repr(C)]
pub struct PoolInfo {
pub last_known_blockchain_height: usize,
}
bitflags::bitflags! {
/// Flags representing the state of the transaction in the pool.
#[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Eq, Ord, Hash, Pod, Zeroable)]