pub struct Mempool(/* private fields */);Expand description
Cheaply cloneable: clones share one live mempool via Arc.
Implementations§
Source§impl Mempool
impl Mempool
Sourcepub fn addr_state_hash(&self, addr: &AddrBytes) -> Option<u64>
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.
Sourcepub fn addr_stats(&self, addr: &AddrBytes) -> Option<AddrMempoolStats>
pub fn addr_stats(&self, addr: &AddrBytes) -> Option<AddrMempoolStats>
Per-address mempool stats. None if the address has no live mempool activity.
Source§impl Mempool
impl Mempool
pub fn next_block_hash(&self) -> NextBlockHash
Sourcepub fn block_template(&self) -> BlockTemplate
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.
Sourcepub fn block_template_diff(
&self,
since: NextBlockHash,
) -> Option<BlockTemplateDiff>
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
impl Mempool
pub fn fees(&self) -> RecommendedFees
pub fn block_stats(&self) -> Vec<BlockStats>
Sourcepub fn live_effective_fee_rate(&self, prefix: &TxidPrefix) -> Option<FeeRate>
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).
Sourcepub fn graveyard_fee_rate(&self, txid: &Txid) -> Option<FeeRate>
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
impl Mempool
pub fn info(&self) -> MempoolInfo
Sourcepub fn live_eligible_histogram(&self) -> HistogramRaw
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.
Sourcepub fn live_raw_histogram(&self) -> HistogramRaw
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
impl Mempool
Sourcepub fn rbf_for_tx(&self, txid: &Txid) -> RbfForTx
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§impl Mempool
impl Mempool
pub fn contains_txid(&self, txid: &Txid) -> bool
Sourcepub fn with_tx<R>(
&self,
txid: &Txid,
f: impl FnOnce(&Transaction) -> R,
) -> Option<R>
pub fn with_tx<R>( &self, txid: &Txid, f: impl FnOnce(&Transaction) -> R, ) -> Option<R>
Apply f to the live tx body if present.
Sourcepub fn with_vanished_tx<R>(
&self,
txid: &Txid,
f: impl FnOnce(&Transaction) -> R,
) -> Option<R>
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.
Sourcepub fn lookup_spender(&self, txid: &Txid, vout: Vout) -> Option<(Txid, Vin)>
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.
Sourcepub fn txids(&self) -> Vec<Txid>
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.
Sourcepub fn recent_txs(&self) -> Vec<MempoolRecentTx>
pub fn recent_txs(&self) -> Vec<MempoolRecentTx>
Snapshot of recent live txs.
Sourcepub fn transaction_times(&self, txids: &[Txid]) -> Vec<u64>
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
impl Mempool
Sourcepub fn start(&self)
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.
Sourcepub fn start_with<F>(&self, resolver: F)
pub fn start_with<F>(&self, resolver: F)
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.
Sourcepub fn tick(&self) -> Result<Cycle>
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.
Sourcepub fn tick_with<F>(&self, resolver: F) -> Result<Cycle>
pub fn tick_with<F>(&self, resolver: F) -> Result<Cycle>
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
impl Mempool
Sourcepub fn cpfp_info(&self, prefix: &TxidPrefix) -> Option<CpfpInfo>
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.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Mempool
impl !UnwindSafe for Mempool
impl Freeze for Mempool
impl Send for Mempool
impl Sync for Mempool
impl Unpin for Mempool
impl UnsafeUnpin for Mempool
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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