Fixes a race condition in CreateNewBlock.

CreateNewBlock was reading pindexBest at the start before taking the lock
so it was possible to have the the block content not match the prevheader.

(Partial of faff50d129)
This commit is contained in:
Gregory Maxwell
2012-10-24 01:41:52 -04:00
committed by Luke Dashjr
parent b3f8f6ab94
commit 2d2e5bdcf4

View File

@@ -3032,7 +3032,7 @@ public:
CBlock* CreateNewBlock(CReserveKey& reservekey)
{
CBlockIndex* pindexPrev = pindexBest;
CBlockIndex* pindexPrev;
// Create new block
auto_ptr<CBlock> pblock(new CBlock());
@@ -3054,6 +3054,7 @@ CBlock* CreateNewBlock(CReserveKey& reservekey)
CRITICAL_BLOCK(cs_main)
CRITICAL_BLOCK(cs_mapTransactions)
{
pindexPrev = pindexBest;
CTxDB txdb("r");
// Priority order to process transactions