Struct near_pool_v01::PoolIteratorWrapper [−][src]
pub struct PoolIteratorWrapper<'a> { /* fields omitted */ }Expand description
PoolIterator is a structure to pull transactions from the pool.
It implements PoolIterator trait that iterates over transaction groups one by one.
When the wrapper is dropped the remaining transactions are returned back to the pool.
Implementations
Trait Implementations
When a pool iterator is dropped, all remaining non empty transaction groups from the sorted groups queue are inserted back into the pool. And removed transactions hashes from groups are removed from the pool’s unique_transactions.
The iterator works with the following algorithm: On next(), the iterator tries to get a transaction group from the pool, sorts transactions in it, and add it to the back of the sorted groups queue. Remembers the last used key, so it can continue from the next key.
If the pool is empty, the iterator gets the group from the front of the sorted groups queue.
If this group is empty (no transactions left inside), then the iterator discards it and
updates unique_transactions in the pool. Then gets the next one.
Once a non-empty group is found, this group is pushed to the back of the sorted groups queue and the iterator returns a mutable reference to this group.
If the sorted groups queue is empty, the iterator returns None.
When the iterator is dropped, unique_transactions in the pool is updated for every group.
And all non-empty group from the sorted groups queue are inserted back into the pool.