added support for multiple chains

This commit is contained in:
Evan Duffield 2014-06-11 15:46:50 -07:00
parent 8c4500dfc5
commit 3a88f95aa1
2 changed files with 22 additions and 10 deletions

View File

@ -9,7 +9,7 @@
#define CLIENT_VERSION_MAJOR 0 #define CLIENT_VERSION_MAJOR 0
#define CLIENT_VERSION_MINOR 9 #define CLIENT_VERSION_MINOR 9
#define CLIENT_VERSION_REVISION 4 #define CLIENT_VERSION_REVISION 4
#define CLIENT_VERSION_BUILD 11 #define CLIENT_VERSION_BUILD 13
// Set to true for release, false for prerelease or test build // Set to true for release, false for prerelease or test build
#define CLIENT_VERSION_IS_RELEASE true #define CLIENT_VERSION_IS_RELEASE true

View File

@ -2621,7 +2621,7 @@ bool CBlock::CheckBlock(CValidationState &state, bool fCheckPOW, bool fCheckMerk
{ {
LOCK2(cs_main, mempool.cs); LOCK2(cs_main, mempool.cs);
CBlockIndex* pindexPrev = pindexBest; CBlockIndex* pindexPrev = NULL;
CBlock blockTmp; CBlock blockTmp;
int votingRecordsBlockPrev = 0; int votingRecordsBlockPrev = 0;
@ -2633,16 +2633,28 @@ bool CBlock::CheckBlock(CValidationState &state, bool fCheckPOW, bool fCheckMerk
int64 masternodePaymentAmount = vtx[0].GetValueOut()/5; int64 masternodePaymentAmount = vtx[0].GetValueOut()/5;
bool fIsInitialDownload = IsInitialBlockDownload(); bool fIsInitialDownload = IsInitialBlockDownload();
CBlock blockLast;
// Work back to the first block in the orphan chain
if (mapBlockIndex.count(hashPrevBlock)){
printf("CheckBlock() : loading prev block %s\n", hashPrevBlock.ToString().c_str());
pindexPrev = mapBlockIndex[hashPrevBlock];
blockLast.ReadFromDisk(pindexPrev);
} else if (mapOrphanBlocks.count(hashPrevBlock)){
printf("CheckBlock() : loading prev orphan block %s\n", hashPrevBlock.ToString().c_str());
blockLast = *mapOrphanBlocks[hashPrevBlock];
} else {
state.DoS(100, error("CheckBlock() : Couldn't load previous block"));
}
if (pindexPrev != NULL && fCheckVotes && !fIsInitialDownload){ if (pindexPrev != NULL && fCheckVotes && !fIsInitialDownload){
CBlock blockLast; {
if(blockLast.ReadFromDisk(pindexPrev)){ if(blockLast.GetHash() != pindexPrev->GetBlockHash()){
if(hashBestChain != pindexPrev->GetBlockHash()){ printf ("CheckBlock() : blockLast.GetHash() != pindexPrev->GetBlockHash() : %s != %s\n", blockLast.GetHash().ToString().c_str(), pindexPrev->GetBlockHash().ToString().c_str());
printf ("CheckBlock() : hashBestChain != pindexPrev->GetBlockHash() : %s != %s\n", hashBestChain.ToString().c_str(), pindexPrev->GetBlockHash().ToString().c_str()); return state.DoS(100, error("CheckBlock() : blockLast.GetHash() != pindexPrev->GetBlockHash()"));
return state.DoS(100, error("CheckBlock() : hashBestChain != pindexPrev->GetBlockHash()"));
} }
printf ("CheckBlock() : nHeight : %d\n", pindexPrev->nHeight); printf ("CheckBlock() : nHeight : %d\n", pindexPrev->nHeight);
printf ("CheckBlock() : hashBestChain : %s\n", hashBestChain.ToString().c_str());
printf ("CheckBlock() : pindexPrev->GetBlockHash() : %s\n", pindexPrev->GetBlockHash().ToString().c_str()); printf ("CheckBlock() : pindexPrev->GetBlockHash() : %s\n", pindexPrev->GetBlockHash().ToString().c_str());
votingRecordsBlockPrev = blockLast.vmn.size(); votingRecordsBlockPrev = blockLast.vmn.size();
@ -2702,7 +2714,7 @@ bool CBlock::CheckBlock(CValidationState &state, bool fCheckPOW, bool fCheckMerk
} }
if(mv2.GetPubKey().size() != 25) if(mv2.GetPubKey().size() != 25)
return state.DoS(0, error("CheckBlock() : pubkey wrong size")); return state.DoS(100, error("CheckBlock() : pubkey wrong size"));
bool found = false; bool found = false;
if(!foundThisBlock && mv2.blockHeight == pindexPrev->nHeight+1) { if(!foundThisBlock && mv2.blockHeight == pindexPrev->nHeight+1) {
@ -2716,7 +2728,7 @@ bool CBlock::CheckBlock(CValidationState &state, bool fCheckPOW, bool fCheckMerk
} }
if(!found) if(!found)
return state.DoS(0, error("CheckBlock() : Vote not found in previous block")); return state.DoS(100, error("CheckBlock() : Vote not found in previous block"));
} }
} }