diff options
author | s_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b> | 2010-08-16 18:46:02 +0000 |
---|---|---|
committer | s_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b> | 2010-08-16 18:46:02 +0000 |
commit | 44a0de1861a78a693ad3331f0f7b06003a78a9d7 (patch) | |
tree | d45c08f097bb8862e5114b99a9229b85ec7d469b | |
parent | a01d5876fa6a9a9fe28cff3ad3ed0e91d5612125 (diff) |
do an extra CheckBlock in ConnectBlock
git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@139 1a98c847-1fd6-4fd8-948a-caf3550aa51b
-rw-r--r-- | db.cpp | 13 | ||||
-rw-r--r-- | main.cpp | 4 | ||||
-rw-r--r-- | serialize.h | 2 |
3 files changed, 6 insertions, 13 deletions
@@ -460,12 +460,9 @@ bool CTxDB::LoadBlockIndex() ReadBestInvalidWork(bnBestInvalidWork);
// Verify blocks in the best chain
- vector<CBlockIndex*> vChain;
- vector<CBlockIndex*> vBad;
CBlockIndex* pindexFork = NULL;
for (CBlockIndex* pindex = pindexBest; pindex && pindex->pprev; pindex = pindex->pprev)
{
- vChain.push_back(pindex);
CBlock block;
if (!block.ReadFromDisk(pindex))
return error("LoadBlockIndex() : block.ReadFromDisk failed");
@@ -473,25 +470,17 @@ bool CTxDB::LoadBlockIndex() {
printf("LoadBlockIndex() : *** found bad block at %d, hash=%s\n", pindex->nHeight, pindex->GetBlockHash().ToString().c_str());
pindexFork = pindex->pprev;
- vBad = vChain;
}
}
if (pindexFork)
{
+ // Reorg back to the fork
printf("LoadBlockIndex() : *** moving best chain pointer back to block %d\n", pindexFork->nHeight);
CBlock block;
if (!block.ReadFromDisk(pindexFork))
return error("LoadBlockIndex() : block.ReadFromDisk failed");
CTxDB txdb;
block.SetBestChain(txdb, pindexFork);
-
- // Delete the bad chain
- foreach(CBlockIndex* pindex, vBad)
- {
- txdb.EraseBlockIndex(pindex->GetBlockHash());
- mapBlockIndex.erase(pindex->GetBlockHash());
- delete pindex;
- }
}
return true;
@@ -1107,6 +1107,10 @@ bool CBlock::DisconnectBlock(CTxDB& txdb, CBlockIndex* pindex) bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex)
{
+ // Check it again in case a previous version let a bad block in
+ if (!CheckBlock())
+ return false;
+
//// issue here: it doesn't know the version
unsigned int nTxPos = pindex->nBlockPos + ::GetSerializeSize(CBlock(), SER_DISK) - 1 + GetSizeOfCompactSize(vtx.size());
diff --git a/serialize.h b/serialize.h index e5e1f0f883..88c2e9ab23 100644 --- a/serialize.h +++ b/serialize.h @@ -20,7 +20,7 @@ class CDataStream; class CAutoFile;
static const int VERSION = 310;
-static const char* pszSubVer = ".2";
+static const char* pszSubVer = ".3";
|