Skip to content

Commit

Permalink
[mempool] Don't throw expected error message when upgrading
Browse files Browse the repository at this point in the history
Summary:
mempool.dat now contains unbroadcast transactions, that did not exist in
mempool.dat files created in previous version.
This commit prevent an uneccessary error message to be logged when users
update from v0.22.11 or lower.
The try..catch can be removed after everyone has upgraded to > v0.22.11.

This is a backport of Core [[bitcoin/bitcoin#18807 | PR18807]] [4/9]
bitcoin/bitcoin@9c8a55d

Test Plan: ninja all check-all

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D9031
  • Loading branch information
amitiuttarwar authored and PiRK committed Jan 22, 2021
1 parent 731ea9c commit 0b9b237
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5850,12 +5850,19 @@ bool LoadMempool(const Config &config, CTxMemPool &pool) {
pool.PrioritiseTransaction(i.first, i.second);
}

std::set<TxId> unbroadcast_txids;
file >> unbroadcast_txids;
unbroadcast = unbroadcast_txids.size();

for (const auto &txid : unbroadcast_txids) {
pool.AddUnbroadcastTx(txid);
// TODO: remove this try...catch after May 15th 2021,
// when no one is running v0.22.11 or lower anymore.
// This will be done by backporting PR20854.
try {
std::set<TxId> unbroadcast_txids;
file >> unbroadcast_txids;
unbroadcast = unbroadcast_txids.size();
for (const auto &txid : unbroadcast_txids) {
pool.AddUnbroadcastTx(txid);
}
} catch (const std::exception &) {
// mempool.dat files created prior to v0.22.12 will not have an
// unbroadcast set. No need to log a failure if parsing fails here.
}

} catch (const std::exception &e) {
Expand Down

0 comments on commit 0b9b237

Please sign in to comment.