Skip to main content

Mempool

Struct Mempool 

Source
pub struct Mempool(/* private fields */);
Expand description

Cheaply cloneable: clones share one live mempool via Arc.

Implementations§

Source§

impl Mempool

Source

pub fn addr_state_hash(&self, addr: &AddrBytes) -> Option<u64>

Hash of the address’s mempool state, None if the address has no live mempool activity. Used as an ETag for address-keyed mempool responses. Route handlers may fall back to a 0 sentinel.

Source

pub fn addr_stats(&self, addr: &AddrBytes) -> Option<AddrMempoolStats>

Per-address mempool stats. None if the address has no live mempool activity.

Source

pub fn addr_txs(&self, addr: &AddrBytes, limit: usize) -> Vec<Transaction>

Live mempool txs touching addr, newest first by first_seen, capped at limit. Returns owned Transactions.

Source§

impl Mempool

Source

pub fn next_block_hash(&self) -> NextBlockHash

Source

pub fn block_template(&self) -> BlockTemplate

Full projected next block: Core’s getblocktemplate selection (block 0) with aggregate stats and full tx bodies in GBT order.

Source

pub fn block_template_diff( &self, since: NextBlockHash, ) -> Option<BlockTemplateDiff>

Delta of the projected next block since since. None when since has aged out of the rebuilder’s history (server should 404 -> client falls back to block_template).

order walks the new template in template order. Each entry is either a Retained index into the prior template (which the client cached when it obtained since) or a New inline body. removed is the convenience list of txids that left.

Source§

impl Mempool

Source

pub fn fees(&self) -> RecommendedFees

Source

pub fn block_stats(&self) -> Vec<BlockStats>

Source

pub fn live_effective_fee_rate(&self, prefix: &TxidPrefix) -> Option<FeeRate>

Effective fee rate for a live tx: snapshot’s linearized chunk rate. Falls back to fee/vsize for txs added since the latest snapshot was built (apply -> same-cycle tick gap).

Source

pub fn graveyard_fee_rate(&self, txid: &Txid) -> Option<FeeRate>

Linearized chunk rate captured at burial - same value live_effective_fee_rate returned while the tx was alive, so an evicted RBF predecessor reports the package-effective rate it had in the mempool, not a misleading isolated fee/vsize.

Source§

impl Mempool

Source

pub fn info(&self) -> MempoolInfo

Source

pub fn live_eligible_histogram(&self) -> HistogramRaw

Snapshot of pre-bucketed round-dollar-eligible bins across all live mempool tx outputs. Maintained incrementally by TxStore on every insert/remove, so this hot path is O(NUM_BINS) regardless of pool size. Used by live_price to blend the mempool into the committed oracle without re-parsing scripts per request.

Source

pub fn live_raw_histogram(&self) -> HistogramRaw

Snapshot of the raw histogram: every live mempool output binned by value with no payment filtering. Backs the histogram/raw/live endpoint.

Source§

impl Mempool

Source

pub fn rbf_for_tx(&self, txid: &Txid) -> RbfForTx

Walk forward through Replaced { by } to the terminal replacer and return its full predecessor tree, plus the requested tx’s direct predecessors. Single read-lock window.

Source

pub fn recent_rbf_trees( &self, full_rbf_only: bool, limit: usize, ) -> Vec<RbfNode>

Recent terminal-replacer trees, most-recent first, deduplicated by root, capped at limit. full_rbf_only drops trees with no non-signaling predecessor.

Source§

impl Mempool

Source

pub fn contains_txid(&self, txid: &Txid) -> bool

Source

pub fn with_tx<R>( &self, txid: &Txid, f: impl FnOnce(&Transaction) -> R, ) -> Option<R>

Apply f to the live tx body if present.

Source

pub fn with_vanished_tx<R>( &self, txid: &Txid, f: impl FnOnce(&Transaction) -> R, ) -> Option<R>

Apply f to a Vanished tombstone’s tx body if present. Replaced tombstones return None because the tx will not confirm.

Source

pub fn lookup_spender(&self, txid: &Txid, vout: Vout) -> Option<(Txid, Vin)>

Mempool tx spending (txid, vout), or None. The spender’s input list is walked to rule out TxidPrefix collisions.

Source

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

Snapshot of all live mempool txids.

Allocates 32 * len(mempool) bytes under the read guard. Sized for diagnostics. Route layers serving large pools should paginate at their boundary rather than calling this per request.

Source

pub fn recent_txs(&self) -> Vec<MempoolRecentTx>

Snapshot of recent live txs.

Source

pub fn transaction_times(&self, txids: &[Txid]) -> Vec<u64>

first_seen Unix-second timestamps for txids, in input order. Returns 0 for unknown txids. Vanished tombstones fall back to the buried entry’s first_seen to avoid flicker between drop and indexer catch-up.

Source§

impl Mempool

Source

pub fn start(&self)

Infinite update loop with a 1s interval. Resolves confirmed-parent prevouts via the default getrawtransaction resolver. Requires bitcoind started with txindex=1. Discards per-cycle Cycle events - use Mempool::tick to consume them.

Source

pub fn start_with<F>(&self, resolver: F)
where F: Fn(&[(Txid, Vout)]) -> FxHashMap<(Txid, Vout), TxOut> + Send,

Variant of start that uses a caller-supplied resolver for confirmed-parent prevouts (typically backed by an indexer).

Sleep is PERIOD - work_duration, so a 350ms cycle followed by a 100ms cycle still ticks roughly every PERIOD. When work overruns PERIOD, the next cycle starts immediately.

§Panics

Panics if a driver is already running on this Mempool instance. One Mempool may host at most one driver. Spawn another instance for additional loops.

Source

pub fn tick(&self) -> Result<Cycle>

One sync cycle: fetch, prepare, apply, fill prevouts, rebuild. Returns a Cycle reporting everything that changed. Uses the default getrawtransaction resolver for confirmed-parent prevouts (requires txindex=1).

§Errors

Propagates any failure from the initial RPC fetch (network drop, auth, bitcoind error). Steps after Fetcher::fetch are infallible today. The resolver itself swallows its own errors and retries next cycle.

Source

pub fn tick_with<F>(&self, resolver: F) -> Result<Cycle>
where F: Fn(&[(Txid, Vout)]) -> FxHashMap<(Txid, Vout), TxOut>,

Variant of Mempool::tick with a caller-supplied resolver for confirmed-parent prevouts. The resolver MUST resolve confirmed prevouts only. Mempool-to-mempool chains are wired internally and the resolver is never called for them.

§Errors

Same as Mempool::tick: only the RPC fetch is fallible.

Source§

impl Mempool

Source

pub fn cpfp_info(&self, prefix: &TxidPrefix) -> Option<CpfpInfo>

CPFP info for a live mempool tx. Returns None when the tx isn’t in the live pool, so callers can fall through to the confirmed path. The snapshot can lag state.txs by up to one cycle: if the seed is in the snapshot but no longer in live state we return None rather than a half-stale report.

Source§

impl Mempool

Source

pub fn new(client: &Client) -> Self

Source

pub fn snapshot(&self) -> Arc<Snapshot>

Source

pub fn stats(&self) -> MempoolStats

One-shot diagnostic counters captured under a single read guard.

Trait Implementations§

Source§

impl Clone for Mempool

Source§

fn clone(&self) -> Mempool

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl From<&Mempool> for MempoolStats

Source§

fn from(mempool: &Mempool) -> Self

Converts to this type from the input type.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

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

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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