Struct Mempool

Source
pub struct Mempool { /* private fields */ }
Available on non-WebAssembly only.
Expand description

Holds the transactions that we broadcasted and are still in the mempool.

Implementations§

Source§

impl Mempool

Source

pub fn new(acc: Pollard<BitcoinNodeHash>, max_mempool_size: usize) -> Mempool

Creates a new mempool with a given maximum size and accumulator.

The acculator should have the same roots as the one inside our chainstate, or we won’t be able to validate proofs.

Source

pub fn list_unprocessed(&self) -> Vec<Txid>

List transactions we are pending to process.

Usually, we don’t have a proof for these transactions, so we can’t add them to the mempool, a wire implementation should call this method and try to get a proof for these transactions.

Source

pub fn list_mempool(&self) -> Vec<Txid>

List all transactions we’ve accepted to the mempool.

This won’t count transactions that are still in the queue.

Source

pub fn get_prevouts(&self, tx: &Transaction) -> Vec<TxOut>

Returns the data of the prevouts that are being spent by a transaction.

This data isn’t part of the actual transaction, usually we would fetch it from the UTXO set, but we don’t have one. Instead, we keep track of the prevouts that are being spent by transactions in the mempool and use this method to get the data.

Source

pub fn try_prove( &self, tx: &Transaction, block_hash: &impl BlockHashOracle, ) -> Result<MempoolProof, AcceptToMempoolError>

Proves that a mempool transaction is valid for the latest accumulator state.

This should return a proof that the transaction is valid, and the data for the prevouts that are being spent by the transaction.

Source

pub fn get_block_template( &self, version: Version, prev_blockhash: BlockHash, time: u32, bits: CompactTarget, ) -> Block

Returns a list of transactions that are in the mempool up to the block weight limit.

Returns a candidate block to be mined.

Source

pub fn consume_block( &mut self, block: &Block, proof: Proof, adds: &[PollardAddition<BitcoinNodeHash>], del_hashes: &[BitcoinNodeHash], block_height: u32, remember_all: bool, ) -> Result<Vec<Txid>, AcceptToMempoolError>

Consume a block and remove all transactions that were included in it.

This method will remove all transactions that is in the block from the mempool, update the local accumulator and return the txids that were included in the block.

Source

pub fn get_block_proof( &self, block: &Block, get_block_hash: impl BlockHashOracle, ) -> Result<MempoolProof, AcceptToMempoolError>

Proves all transactions included in a block.

Source

pub fn accept_to_mempool_no_acc( &mut self, transaction: Transaction, ) -> Result<(), AcceptToMempoolError>

Internal utility to add a transaction to the mempool.

This method should never be called for transactions coming from the wire, since it doesn’t check if the transaction is valid other than basic constraint checks. This method is used by the mempool itself to add transactions that are already known to be valid, such as wallet transactions. For transactions coming from the wire, use accept_to_mempool.

Source

pub fn accept_to_mempool( &mut self, transaction: Transaction, proof: Proof, prevouts: &[(OutPoint, CompactLeafData)], del_hashes: &[BitcoinNodeHash], remembers: &[u64], ) -> Result<(), AcceptToMempoolError>

Add a transaction to the mempool.

Source

pub fn get_from_mempool<'a>(&'a self, id: &Txid) -> Option<&'a Transaction>

Get a transaction from the mempool.

Source

pub fn get_stale(&mut self) -> Vec<Txid>

Get all transactions that were in the mempool for more than 1 hour, if any

Trait Implementations§

Source§

impl Debug for Mempool

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Send for Mempool

Auto Trait Implementations§

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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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>,

Source§

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more