Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Mempool architecture diagram

The Mempool service owns storage and download/verification tasks. The downloader returns candidates; only the service admits them to storage. Arrows carry requests or events; gossip_mempool_transaction_id is a task, not a Tower service.

flowchart TD
    inbound["Inbound"] -->|QueueFromPeer| mempool["Mempool"]
    rpc["RpcImpl"] -->|Queue or queries| mempool
    crawler["Crawler"] -->|MempoolTransactionIds| network["NetworkService / PeerSet"]
    crawler -->|Queue| mempool
    checker["QueueChecker"] -->|CheckForVerifiedTransactions| mempool

    mempool -->|admit candidate| downloads["Downloads"]
    downloads -->|TransactionsById when needed| network
    downloads -->|Transaction and Tip queries| state["StateService"]
    downloads -->|MempoolRequest| verifier["MempoolTxVerifier"]
    verifier -->|unspent outputs, anchors, nullifiers, time| state
    verifier -->|AwaitOutput| mempool
    downloads -->|completed results in poll_ready| mempool

    mempool -->|insert or remove| storage["Storage"]
    storage --> verified["VerifiedSet"]
    storage --> pending["PendingOutputs"]
    storage --> rejected["EvictionList"]
    tip["ChainTipChange / LatestChainTip"] --> mempool
    status["SyncStatus"] -->|initial activation| mempool
    status -->|crawl gating| crawler

    mempool -->|MempoolChange added| gossip["gossip_mempool_transaction_id"]
    gossip -->|AdvertiseTransactionIds| network

Components

ComponentResponsibility
MempoolDispatch requests, collect completed verification results in poll_ready, update storage for tip changes, and publish MempoolChange events.
DownloadsDeduplicate queued candidates, enforce global and per-peer admission bounds, check whether a transaction is already mined, download missing bytes, and call the verifier.
MempoolTxVerifierVerify for the next block height using chain state and, for transparent dependencies, outputs awaited from the mempool.
StorageApply standardness and cost-limit policy; own the verified set, pending-output requests, and rejection caches.
VerifiedSetIndex transactions, created and spent outputs, nullifiers, and dependencies; perform weighted eviction and remove dependent transactions.
PendingOutputsHold callers waiting for transparent outputs and respond when a parent transaction is inserted.
EvictionListRetain bounded, timed lists of transaction IDs rejected for chain effects, including random eviction.
CrawlerQuery peer mempools and queue returned IDs.
QueueCheckerTrigger completion processing without external requests.
gossip_mempool_transaction_idConsume added-transaction events, combine available IDs, and advertise them through the network service.

The mempool specification defines activation, task startup and timing, admission, eviction, rejection lifetimes, tip resets, and the service API.