[#Chainstate-MaybeUpdateMempoolForReorg]
= xref:Chainstate.adoc[Chainstate]::MaybeUpdateMempoolForReorg
:relfileprefix: ../
:mrdocs:

Make mempool consistent after a reorg, by re&hyphen;adding or recursively erasing disconnected block transactions from the mempool, and also removing any other transactions from the mempool that are no longer valid given the new tip&sol;height&period;

== Synopsis

Declared in `&lt;validation&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
&lsqb;&lsqb;requires&lowbar;capability(0x7f2e1ba85a78, 0x7f2e1ba85af0), requires&lowbar;capability(0x7f2e145656c8, 0x7f2e14565740), requires&lowbar;capability(0x7f2e373be878, 0x7f2e373be8f0), requires&lowbar;capability(0x7f2e36e354c8, 0x7f2e36e35540)&rsqb;&rsqb;
void
MaybeUpdateMempoolForReorg(
    xref:DisconnectedBlockTransactions.adoc[DisconnectedBlockTransactions]& disconnectpool,
    bool fAddToMempool);
----

== Description

Note&colon; we assume that disconnectpool only contains transactions that are NOT confirmed in the current chain nor already in the mempool (otherwise, in&hyphen;mempool descendants of such transactions would be removed)&period;

Passing fAddToMempool&equals;false will skip trying to add the transactions back, and instead just erase from the mempool as needed&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *disconnectpool*
| Transactions from disconnected blocks to re&hyphen;add or erase&period;
| *fAddToMempool*
| Whether to try re&hyphen;adding the disconnected transactions&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
