mirror of
https://github.com/Cuprate/cuprate.git
synced 2024-11-16 15:58:17 +00:00
remove blockchain height from txpool
This commit is contained in:
parent
bfb4cbf831
commit
6c1f871d81
5 changed files with 5 additions and 43 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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>,
|
||||
},
|
||||
|
|
|
@ -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(())
|
||||
};
|
||||
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
|
|
|
@ -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)]
|
||||
|
|
Loading…
Reference in a new issue