fixed log message and added checkpoint

This commit is contained in:
Evan Duffield 2015-02-10 03:45:21 -07:00
parent e6ec9665d5
commit ba12e5905e
2 changed files with 44 additions and 39 deletions

View File

@ -56,6 +56,7 @@ namespace Checkpoints
( 137993, uint256("0x00000000000cf69ce152b1bffdeddc59188d7a80879210d6e5c9503011929c3c")) ( 137993, uint256("0x00000000000cf69ce152b1bffdeddc59188d7a80879210d6e5c9503011929c3c"))
( 167996, uint256("0x000000000009486020a80f7f2cc065342b0c2fb59af5e090cd813dba68ab0fed")) ( 167996, uint256("0x000000000009486020a80f7f2cc065342b0c2fb59af5e090cd813dba68ab0fed"))
( 207992, uint256("0x00000000000d85c22be098f74576ef00b7aa00c05777e966aff68a270f1e01a5")) ( 207992, uint256("0x00000000000d85c22be098f74576ef00b7aa00c05777e966aff68a270f1e01a5"))
( 217752, uint256("0x00000000000a7baeb2148272a7e14edf5af99a64af456c0afc23d15a0918b704"))
; ;
static const CCheckpointData data = { static const CCheckpointData data = {
&mapCheckpoints, &mapCheckpoints,

View File

@ -2867,60 +2867,64 @@ bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bo
if(fDebug) LogPrintf("CheckBlock() : Masternode payment enforcement is off\n"); if(fDebug) LogPrintf("CheckBlock() : Masternode payment enforcement is off\n");
} }
if(MasternodePayments && !fLargeWorkForkFound && !fLargeWorkInvalidChainFound) if(!fLargeWorkForkFound && !fLargeWorkInvalidChainFound){
{ if(MasternodePayments)
LOCK2(cs_main, mempool.cs); {
LOCK2(cs_main, mempool.cs);
CBlockIndex *pindex = chainActive.Tip(); CBlockIndex *pindex = chainActive.Tip();
if(pindex != NULL){ if(pindex != NULL){
if(pindex->GetBlockHash() == block.hashPrevBlock){ if(pindex->GetBlockHash() == block.hashPrevBlock){
int64_t masternodePaymentAmount = GetMasternodePayment(pindex->nHeight+1, block.vtx[0].GetValueOut()); int64_t masternodePaymentAmount = GetMasternodePayment(pindex->nHeight+1, block.vtx[0].GetValueOut());
bool fIsInitialDownload = IsInitialBlockDownload(); bool fIsInitialDownload = IsInitialBlockDownload();
// If we don't already have its previous block, skip masternode payment step // If we don't already have its previous block, skip masternode payment step
if (!fIsInitialDownload && pindex != NULL) if (!fIsInitialDownload && pindex != NULL)
{ {
bool foundPaymentAmount = false; bool foundPaymentAmount = false;
bool foundPayee = false; bool foundPayee = false;
bool foundPaymentAndPayee = false; bool foundPaymentAndPayee = false;
CScript payee; CScript payee;
if(!masternodePayments.GetBlockPayee(chainActive.Tip()->nHeight+1, payee) || payee == CScript()){ if(!masternodePayments.GetBlockPayee(chainActive.Tip()->nHeight+1, payee) || payee == CScript()){
foundPayee = true; //doesn't require a specific payee foundPayee = true; //doesn't require a specific payee
foundPaymentAmount = true;
foundPaymentAndPayee = true;
LogPrintf("CheckBlock() : Using non-specific masternode payments %d\n", chainActive.Tip()->nHeight+1);
}
for (unsigned int i = 0; i < block.vtx[0].vout.size(); i++) {
if(block.vtx[0].vout[i].nValue == masternodePaymentAmount )
foundPaymentAmount = true; foundPaymentAmount = true;
if(block.vtx[0].vout[i].scriptPubKey == payee )
foundPayee = true;
if(block.vtx[0].vout[i].nValue == masternodePaymentAmount && block.vtx[0].vout[i].scriptPubKey == payee)
foundPaymentAndPayee = true; foundPaymentAndPayee = true;
} LogPrintf("CheckBlock() : Using non-specific masternode payments %d\n", chainActive.Tip()->nHeight+1);
}
if(!foundPaymentAndPayee) { for (unsigned int i = 0; i < block.vtx[0].vout.size(); i++) {
CTxDestination address1; if(block.vtx[0].vout[i].nValue == masternodePaymentAmount )
ExtractDestination(payee, address1); foundPaymentAmount = true;
CBitcoinAddress address2(address1); if(block.vtx[0].vout[i].scriptPubKey == payee )
foundPayee = true;
if(block.vtx[0].vout[i].nValue == masternodePaymentAmount && block.vtx[0].vout[i].scriptPubKey == payee)
foundPaymentAndPayee = true;
}
LogPrintf("CheckBlock() : Couldn't find masternode payment(%d|%d) or payee(%d|%s) nHeight %d. \n", foundPaymentAmount, masternodePaymentAmount, foundPayee, address2.ToString().c_str(), chainActive.Tip()->nHeight+1); if(!foundPaymentAndPayee) {
if(!RegTest()) return state.DoS(100, error("CheckBlock() : Couldn't find masternode payment or payee")); CTxDestination address1;
ExtractDestination(payee, address1);
CBitcoinAddress address2(address1);
LogPrintf("CheckBlock() : Couldn't find masternode payment(%d|%d) or payee(%d|%s) nHeight %d. \n", foundPaymentAmount, masternodePaymentAmount, foundPayee, address2.ToString().c_str(), chainActive.Tip()->nHeight+1);
if(!RegTest()) return state.DoS(100, error("CheckBlock() : Couldn't find masternode payment or payee"));
} else {
LogPrintf("CheckBlock() : Found masternode payment %d\n", chainActive.Tip()->nHeight+1);
}
} else { } else {
LogPrintf("CheckBlock() : Found masternode payment %d\n", chainActive.Tip()->nHeight+1); LogPrintf("CheckBlock() : Is initial download, skipping masternode payment check %d\n", chainActive.Tip()->nHeight+1);
} }
} else { } else {
LogPrintf("CheckBlock() : Is initial download, skipping masternode payment check %d\n", chainActive.Tip()->nHeight+1); LogPrintf("CheckBlock() : Skipping masternode payment check - nHeight %d Hash %s\n", chainActive.Tip()->nHeight+1, block.GetHash().ToString().c_str());
} }
} else { } else {
LogPrintf("CheckBlock() : Skipping masternode payment check - nHeight %d Hash %s\n", chainActive.Tip()->nHeight+1, block.GetHash().ToString().c_str()); LogPrintf("CheckBlock() : pindex is null, skipping masternode payment check\n");
} }
} else { } else {
LogPrintf("CheckBlock() : pindex is null, skipping masternode payment check\n"); LogPrintf("CheckBlock() : skipping masternode payment checks\n");
} }
} else { } else {
LogPrintf("CheckBlock() : fork detected, skipping masternode payment checks\n"); LogPrintf("CheckBlock() : fork detected, skipping masternode payment checks\n");
} }