Struct grin_pool::Pool

source ·
pub struct Pool<B>
where B: BlockChain,
{ pub entries: Vec<PoolEntry>, pub blockchain: Arc<B>, pub name: String, }

Fields§

§entries: Vec<PoolEntry>

Entries in the pool (tx + info + timer) in simple insertion order.

§blockchain: Arc<B>

The blockchain

§name: String

Implementations§

source§

impl<B> Pool<B>
where B: BlockChain,

source

pub fn new(chain: Arc<B>, name: String) -> Self

source

pub fn contains_tx(&self, tx: &Transaction) -> bool

Does the transaction pool contain an entry for the given transaction? Transactions are compared by their kernels.

source

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

Query the tx pool for an individual tx matching the given kernel hash.

source

pub fn retrieve_transactions( &self, hash: Hash, nonce: u64, kern_ids: &[ShortId] ) -> (Vec<Transaction>, Vec<ShortId>)

Query the tx pool for all known txs based on kernel short_ids from the provided compact_block. Note: does not validate that we return the full set of required txs. The caller will need to validate that themselves.

source

pub fn prepare_mineable_transactions( &self, max_weight: u64 ) -> Result<Vec<Transaction>, PoolError>

Take pool transactions, filtering and ordering them in a way that’s appropriate to put in a mined block. Aggregates chains of dependent transactions, orders by fee over weight and ensures the total weight does not exceed the provided max_weight (miner defined block weight).

source

pub fn all_transactions(&self) -> Vec<Transaction>

source

pub fn all_transactions_aggregate( &self, extra_tx: Option<Transaction> ) -> Result<Option<Transaction>, PoolError>

Return a single aggregate tx representing all txs in the pool. Takes an optional “extra tx” to include in the aggregation. Returns None if there is nothing to aggregate. Returns the extra tx if provided and pool is empty.

source

pub fn add_to_pool( &mut self, entry: PoolEntry, extra_tx: Option<Transaction>, header: &BlockHeader ) -> Result<(), PoolError>

source

pub fn validate_raw_txs( &self, txs: &[Transaction], extra_tx: Option<Transaction>, header: &BlockHeader, weighting: Weighting ) -> Result<Vec<Transaction>, PoolError>

source

pub fn locate_spends( &self, tx: &Transaction, extra_tx: Option<Transaction> ) -> Result<(Vec<OutputIdentifier>, Vec<OutputIdentifier>), PoolError>

Lookup unspent outputs to be spent by the provided transaction. We look for unspent outputs in the current txpool and then in the current utxo.

source

pub fn reconcile( &mut self, extra_tx: Option<Transaction>, header: &BlockHeader ) -> Result<(), PoolError>

source

pub fn evict_transaction(&mut self)

source

pub fn find_matching_transactions( &self, kernels: &[TxKernel] ) -> Vec<Transaction>

TODO - This is kernel based. How does this interact with NRD?

source

pub fn reconcile_block(&mut self, block: &Block)

Quick reconciliation step - we can evict any txs in the pool where inputs or kernels intersect with the block.

source

pub fn size(&self) -> usize

Size of the pool.

source

pub fn kernel_count(&self) -> usize

Number of transaction kernels in the pool. This may differ from the size (number of transactions) due to tx aggregation.

source

pub fn is_empty(&self) -> bool

Is the pool empty?

Auto Trait Implementations§

§

impl<B> Freeze for Pool<B>

§

impl<B> RefUnwindSafe for Pool<B>
where B: RefUnwindSafe,

§

impl<B> Send for Pool<B>

§

impl<B> Sync for Pool<B>

§

impl<B> Unpin for Pool<B>

§

impl<B> UnwindSafe for Pool<B>
where B: RefUnwindSafe,

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,