Merge #739: Take mempool locks when doing compact block RPC calls touching mempool

67a669e69 Take mempool locks when doing compact block RPC calls touching mempool (Gregory Sanders)

Pull request description:

  This may help reduce the failures in `feature_blocksign.py` that seem to occur fairly often. It could be that the mempool is in an inconsistent state, which messed up compact block finalization.

Tree-SHA512: cd066933cf58b3c57869db3fd97c2de0ff554d442e91051f43626b12778d55835065ad5fc42fed09b7750796e9e0b2e6947f1ac54e02fe4c8e2a84fe340429ae
This commit is contained in:
Gregory Sanders 2019-10-09 13:13:04 -04:00
commit 81fd79ab94
No known key found for this signature in database
GPG key ID: F3F68E2D86A48FDB

View file

@ -1245,6 +1245,7 @@ UniValue consumecompactsketch(const JSONRPCRequest& request)
CBlockHeaderAndShortTxIDs cmpctblock;
ssBlock >> cmpctblock;
LOCK(mempool.cs);
PartiallyDownloadedBlock partialBlock(&mempool);
const std::vector<std::pair<uint256, CTransactionRef>> dummy;
ReadStatus status = partialBlock.InitData(cmpctblock, dummy);
@ -1376,6 +1377,7 @@ UniValue finalizecompactblock(const JSONRPCRequest& request)
found.insert(found.end(), transactions.txn.begin(), transactions.txn.end());
// Now construct the final block!
LOCK(mempool.cs);
PartiallyDownloadedBlock partialBlock(&mempool);
const std::vector<std::pair<uint256, CTransactionRef>> dummy;