From 929cc7c0395e275ebc3fe07eb4ed8fbbabdd4a16 Mon Sep 17 00:00:00 2001 From: Evan Duffield Date: Fri, 9 May 2014 06:27:03 -0700 Subject: [PATCH] fixed rc2 edge case and removed debug comments --- src/main.cpp | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index b8446607bc..31e04f9dbe 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -838,7 +838,6 @@ bool CTxMemPool::acceptableInputs(CValidationState &state, CTransaction &tx, boo COutPoint outpoint = tx.vin[i].prevout; if (mapNextTx.count(outpoint)) { - printf("false2\n"); // Disable replacement feature for now return false; } @@ -859,14 +858,12 @@ bool CTxMemPool::acceptableInputs(CValidationState &state, CTransaction &tx, boo // only helps filling in pfMissingInputs (to determine missing vs spent). BOOST_FOREACH(const CTxIn txin, tx.vin) { if (!view.HaveCoins(txin.prevout.hash)) { - printf("false4\n"); return false; } } // are the actual inputs available? if (!tx.HaveInputs(view)) { - printf("false5\n"); return state.Invalid(error("CTxMemPool::acceptableInputs() : inputs already spent")); } @@ -881,7 +878,6 @@ bool CTxMemPool::acceptableInputs(CValidationState &state, CTransaction &tx, boo // This is done last to help prevent CPU exhaustion denial-of-service attacks. if (!tx.CheckInputs(state, view, false, SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_STRICTENC)) { - printf("false8\n"); return error("CTxMemPool::acceptableInputs() : ConnectInputs failed \n"); } } @@ -918,7 +914,6 @@ bool CTxMemPool::acceptable(CValidationState &state, CTransaction &tx, bool fChe { LOCK(cs); if (mapTx.count(hash)) { - printf("false1\n"); return false; } } @@ -929,7 +924,6 @@ bool CTxMemPool::acceptable(CValidationState &state, CTransaction &tx, bool fChe COutPoint outpoint = tx.vin[i].prevout; if (mapNextTx.count(outpoint)) { - printf("false2\n"); // Disable replacement feature for now return false; } @@ -947,7 +941,6 @@ bool CTxMemPool::acceptable(CValidationState &state, CTransaction &tx, bool fChe // do we already have it? if (view.HaveCoins(hash)){ - printf("false3\n"); return false; } @@ -958,14 +951,12 @@ bool CTxMemPool::acceptable(CValidationState &state, CTransaction &tx, bool fChe if (!view.HaveCoins(txin.prevout.hash)) { if (pfMissingInputs) *pfMissingInputs = true; - printf("false4\n"); return false; } } // are the actual inputs available? if (!tx.HaveInputs(view)) { - printf("false5\n"); return state.Invalid(error("CTxMemPool::acceptable() : inputs already spent")); } @@ -978,7 +969,6 @@ bool CTxMemPool::acceptable(CValidationState &state, CTransaction &tx, bool fChe // Check for non-standard pay-to-script-hash in inputs if (!tx.AreInputsStandard(view) && !fTestNet) { - printf("false6\n"); return error("CTxMemPool::acceptable() : nonstandard transaction input"); } @@ -991,7 +981,6 @@ bool CTxMemPool::acceptable(CValidationState &state, CTransaction &tx, bool fChe // Don't accept it if it can't get into a block int64 txMinFee = tx.GetMinFee(1000, true, GMF_RELAY); if (fLimitFree && nFees < txMinFee) { - printf("false7\n"); return error("CTxMemPool::acceptable() : not enough fees %s, %"PRI64d" < %"PRI64d, hash.ToString().c_str(), nFees, txMinFee); @@ -1001,7 +990,6 @@ bool CTxMemPool::acceptable(CValidationState &state, CTransaction &tx, bool fChe // This is done last to help prevent CPU exhaustion denial-of-service attacks. if (!tx.CheckInputs(state, view, true, SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_STRICTENC)) { - printf("false8\n"); return error("CTxMemPool::acceptable() : ConnectInputs failed %s", hash.ToString().c_str()); } } @@ -2609,10 +2597,12 @@ bool CBlock::CheckBlock(CValidationState &state, bool fCheckPOW, bool fCheckMerk int badVote = 0; int foundMasterNodePaymentPrev = 0; int foundMasterNodePayment = 0; + int removedMasterNodePayments = 0; int64 masternodePaymentAmount = vtx[0].GetValueOut()/10; + bool fIsInitialDownload = IsInitialBlockDownload(); - if (pindexPrev != NULL && fCheckVotes){ + if (pindexPrev != NULL && fCheckVotes && !fIsInitialDownload){ CBlock blockLast; if(blockLast.ReadFromDisk(pindexPrev)){ votingRecordsBlockPrev = blockLast.vmn.size(); @@ -2620,10 +2610,8 @@ bool CBlock::CheckBlock(CValidationState &state, bool fCheckPOW, bool fCheckMerk if((pindexPrev->nHeight+1) - mv1.GetHeight() > MASTERNODE_PAYMENTS_EXPIRATION){ return state.DoS(100, error("CheckBlock() : Vote too old")); } else if((pindexPrev->nHeight+1) - mv1.GetHeight() == MASTERNODE_PAYMENTS_EXPIRATION){ - votingRecordsBlockPrev--; - } - - if(mv1.GetVotes() == MASTERNODE_PAYMENTS_MIN_VOTES-1 && foundMasterNodePaymentPrev <= MASTERNODE_PAYMENTS_MAX) { + removedMasterNodePayments++; + } else if(mv1.GetVotes() == MASTERNODE_PAYMENTS_MIN_VOTES-1 && foundMasterNodePaymentPrev <= MASTERNODE_PAYMENTS_MAX) { for (unsigned int i = 1; i < vtx[0].vout.size(); i++) if(vtx[0].vout[i].nValue == masternodePaymentAmount && mv1.GetPubKey() == vtx[0].vout[i].scriptPubKey) foundMasterNodePayment++; @@ -2664,9 +2652,9 @@ bool CBlock::CheckBlock(CValidationState &state, bool fCheckPOW, bool fCheckMerk if(foundMasterNodePayment!=foundMasterNodePaymentPrev) return state.DoS(100, error("CheckBlock() : Required masternode payment missing")); - if(matchingVoteRecords+foundMasterNodePayment!=votingRecordsBlockPrev) + if(matchingVoteRecords+foundMasterNodePayment+removedMasterNodePayments!=votingRecordsBlockPrev) return state.DoS(100, error("CheckBlock() : Missing masternode votes")); - + if(matchingVoteRecords+foundMasterNodePayment>MASTERNODE_PAYMENTS_EXPIRATION) return state.DoS(100, error("CheckBlock() : Too many vote records found")); } @@ -3967,6 +3955,9 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) if (pfrom->nVersion != darkSendPool.MIN_PEER_PROTO_VERSION) { return false; } + bool fIsInitialDownload = IsInitialBlockDownload(); + if(fIsInitialDownload) return true; + CTxIn vin; CService addr; CPubKey pubkey;