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,

source

pub fn new(config: PoolConfig, chain: Arc<B>, adapter: Arc<P>) -> Self

Create a new transaction pool

source

pub fn chain_head(&self) -> Result<BlockHeader, PoolError>

source

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.

source

pub fn evict_from_txpool(&mut self)

source

pub fn truncate_reorg_cache(&mut self, cutoff: DateTime<Utc>)

source

pub fn reconcile_reorg_cache( &mut self, header: &BlockHeader ) -> Result<(), PoolError>

source

pub fn reconcile_block(&mut self, block: &Block) -> Result<(), PoolError>

Reconcile the transaction pool (both txpool and stempool) against the provided block.

source

pub fn retrieve_tx_by_kernel_hash(&self, hash: Hash) -> Option<Transaction>

Retrieve individual transaction for the given kernel hash.

source

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).

source

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.

source

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.

Auto Trait Implementations§

§

impl<B, P> Freeze for TransactionPool<B, P>

§

impl<B, P> !RefUnwindSafe for TransactionPool<B, P>

§

impl<B, P> Send for TransactionPool<B, P>

§

impl<B, P> Sync for TransactionPool<B, P>

§

impl<B, P> Unpin for TransactionPool<B, P>

§

impl<B, P> !UnwindSafe for TransactionPool<B, P>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> UnsafeAny for T
where T: Any,