More debug output for failed reorganizations

This commit is contained in:
Pieter Wuille 2012-03-21 13:15:27 +01:00
parent 6565f4e855
commit a1a0469f91

View File

@ -1382,6 +1382,9 @@ bool static Reorganize(CTxDB& txdb, CBlockIndex* pindexNew)
vConnect.push_back(pindex); vConnect.push_back(pindex);
reverse(vConnect.begin(), vConnect.end()); reverse(vConnect.begin(), vConnect.end());
printf("REORGANIZE: Disconnect %i blocks; %s..%s\n", vDisconnect.size(), pfork->GetBlockHash().ToString().substr(0,20).c_str(), pindexBest->GetBlockHash().ToString().substr(0,20).c_str());
printf("REORGANIZE: Connect %i blocks; %s..%s\n", vConnect.size(), pfork->GetBlockHash().ToString().substr(0,20).c_str(), pindexNew->GetBlockHash().ToString().substr(0,20).c_str());
// Disconnect shorter branch // Disconnect shorter branch
vector<CTransaction> vResurrect; vector<CTransaction> vResurrect;
BOOST_FOREACH(CBlockIndex* pindex, vDisconnect) BOOST_FOREACH(CBlockIndex* pindex, vDisconnect)
@ -1390,7 +1393,7 @@ bool static Reorganize(CTxDB& txdb, CBlockIndex* pindexNew)
if (!block.ReadFromDisk(pindex)) if (!block.ReadFromDisk(pindex))
return error("Reorganize() : ReadFromDisk for disconnect failed"); return error("Reorganize() : ReadFromDisk for disconnect failed");
if (!block.DisconnectBlock(txdb, pindex)) if (!block.DisconnectBlock(txdb, pindex))
return error("Reorganize() : DisconnectBlock failed"); return error("Reorganize() : DisconnectBlock %s failed", pindex->GetBlockHash().ToString().substr(0,20).c_str());
// Queue memory transactions to resurrect // Queue memory transactions to resurrect
BOOST_FOREACH(const CTransaction& tx, block.vtx) BOOST_FOREACH(const CTransaction& tx, block.vtx)
@ -1410,7 +1413,7 @@ bool static Reorganize(CTxDB& txdb, CBlockIndex* pindexNew)
{ {
// Invalid block // Invalid block
txdb.TxnAbort(); txdb.TxnAbort();
return error("Reorganize() : ConnectBlock failed"); return error("Reorganize() : ConnectBlock %s failed", pindex->GetBlockHash().ToString().substr(0,20).c_str());
} }
// Queue memory transactions to delete // Queue memory transactions to delete
@ -1442,8 +1445,7 @@ bool static Reorganize(CTxDB& txdb, CBlockIndex* pindexNew)
BOOST_FOREACH(CTransaction& tx, vDelete) BOOST_FOREACH(CTransaction& tx, vDelete)
tx.RemoveFromMemoryPool(); tx.RemoveFromMemoryPool();
printf("REORGANIZE: Disconnected %i blocks; %s..%s\n", vDisconnect.size(), pfork->GetBlockHash().ToString().substr(0,20).c_str(), pindexBest->GetBlockHash().ToString().substr(0,20).c_str()); printf("REORGANIZE: done\n");
printf("REORGANIZE: Connected %i blocks; %s..%s\n", vConnect.size(), pfork->GetBlockHash().ToString().substr(0,20).c_str(), pindexNew->GetBlockHash().ToString().substr(0,20).c_str());
return true; return true;
} }