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"))
( 167996, uint256("0x000000000009486020a80f7f2cc065342b0c2fb59af5e090cd813dba68ab0fed"))
( 207992, uint256("0x00000000000d85c22be098f74576ef00b7aa00c05777e966aff68a270f1e01a5"))
( 217752, uint256("0x00000000000a7baeb2148272a7e14edf5af99a64af456c0afc23d15a0918b704"))
;
static const CCheckpointData data = {
&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(MasternodePayments && !fLargeWorkForkFound && !fLargeWorkInvalidChainFound)
{
LOCK2(cs_main, mempool.cs);
if(!fLargeWorkForkFound && !fLargeWorkInvalidChainFound){
if(MasternodePayments)
{
LOCK2(cs_main, mempool.cs);
CBlockIndex *pindex = chainActive.Tip();
if(pindex != NULL){
if(pindex->GetBlockHash() == block.hashPrevBlock){
int64_t masternodePaymentAmount = GetMasternodePayment(pindex->nHeight+1, block.vtx[0].GetValueOut());
bool fIsInitialDownload = IsInitialBlockDownload();
CBlockIndex *pindex = chainActive.Tip();
if(pindex != NULL){
if(pindex->GetBlockHash() == block.hashPrevBlock){
int64_t masternodePaymentAmount = GetMasternodePayment(pindex->nHeight+1, block.vtx[0].GetValueOut());
bool fIsInitialDownload = IsInitialBlockDownload();
// If we don't already have its previous block, skip masternode payment step
if (!fIsInitialDownload && pindex != NULL)
{
bool foundPaymentAmount = false;
bool foundPayee = false;
bool foundPaymentAndPayee = false;
// If we don't already have its previous block, skip masternode payment step
if (!fIsInitialDownload && pindex != NULL)
{
bool foundPaymentAmount = false;
bool foundPayee = false;
bool foundPaymentAndPayee = false;
CScript payee;
if(!masternodePayments.GetBlockPayee(chainActive.Tip()->nHeight+1, payee) || payee == CScript()){
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 )
CScript payee;
if(!masternodePayments.GetBlockPayee(chainActive.Tip()->nHeight+1, payee) || payee == CScript()){
foundPayee = true; //doesn't require a specific payee
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;
}
LogPrintf("CheckBlock() : Using non-specific masternode payments %d\n", chainActive.Tip()->nHeight+1);
}
if(!foundPaymentAndPayee) {
CTxDestination address1;
ExtractDestination(payee, address1);
CBitcoinAddress address2(address1);
for (unsigned int i = 0; i < block.vtx[0].vout.size(); i++) {
if(block.vtx[0].vout[i].nValue == masternodePaymentAmount )
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;
}
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"));
if(!foundPaymentAndPayee) {
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 {
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 {
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 {
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 {
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");
}