Struct grin_pool::transaction_pool::TransactionPool
source · pub struct TransactionPool<B, P>where
B: BlockChain,
P: PoolAdapter,{
pub config: PoolConfig,
pub txpool: Pool<B>,
pub stempool: Pool<B>,
pub reorg_cache: Arc<RwLock<VecDeque<PoolEntry>>>,
pub blockchain: Arc<B>,
pub adapter: Arc<P>,
}
Expand description
Transaction pool implementation.
Fields§
§config: PoolConfig
Pool Config
txpool: Pool<B>
Our transaction pool.
stempool: Pool<B>
Our Dandelion “stempool”.
reorg_cache: Arc<RwLock<VecDeque<PoolEntry>>>
Cache of previous txs in case of a re-org.
blockchain: Arc<B>
The blockchain
adapter: Arc<P>
The pool adapter
Implementations§
source§impl<B, P> TransactionPool<B, P>where
B: BlockChain,
P: PoolAdapter,
impl<B, P> TransactionPool<B, P>where
B: BlockChain,
P: PoolAdapter,
sourcepub fn new(config: PoolConfig, chain: Arc<B>, adapter: Arc<P>) -> Self
pub fn new(config: PoolConfig, chain: Arc<B>, adapter: Arc<P>) -> Self
Create a new transaction pool
pub fn chain_head(&self) -> Result<BlockHeader, PoolError>
sourcepub fn add_to_pool(
&mut self,
src: TxSource,
tx: Transaction,
stem: bool,
header: &BlockHeader
) -> Result<(), PoolError>
pub fn add_to_pool( &mut self, src: TxSource, tx: Transaction, stem: bool, header: &BlockHeader ) -> Result<(), PoolError>
Add the given tx to the pool, directing it to either the stempool or txpool based on stem flag provided.
pub fn evict_from_txpool(&mut self)
pub fn truncate_reorg_cache(&mut self, cutoff: DateTime<Utc>)
pub fn reconcile_reorg_cache( &mut self, header: &BlockHeader ) -> Result<(), PoolError>
sourcepub fn reconcile_block(&mut self, block: &Block) -> Result<(), PoolError>
pub fn reconcile_block(&mut self, block: &Block) -> Result<(), PoolError>
Reconcile the transaction pool (both txpool and stempool) against the provided block.
sourcepub fn retrieve_tx_by_kernel_hash(&self, hash: Hash) -> Option<Transaction>
pub fn retrieve_tx_by_kernel_hash(&self, hash: Hash) -> Option<Transaction>
Retrieve individual transaction for the given kernel hash.
sourcepub fn retrieve_transactions(
&self,
hash: Hash,
nonce: u64,
kern_ids: &[ShortId]
) -> (Vec<Transaction>, Vec<ShortId>)
pub fn retrieve_transactions( &self, hash: Hash, nonce: u64, kern_ids: &[ShortId] ) -> (Vec<Transaction>, Vec<ShortId>)
Retrieve all transactions matching the provided “compact block” based on the kernel set. Note: we only look in the txpool for this (stempool is under embargo).
sourcepub fn total_size(&self) -> usize
pub fn total_size(&self) -> usize
Get the total size of the pool. Note: we only consider the txpool here as stempool is under embargo.
sourcepub fn prepare_mineable_transactions(
&self
) -> Result<Vec<Transaction>, PoolError>
pub fn prepare_mineable_transactions( &self ) -> Result<Vec<Transaction>, PoolError>
Returns a vector of transactions from the txpool so we can build a block from them.