fixed rc2 edge case and removed debug comments

This commit is contained in:
Evan Duffield 2014-05-09 06:27:03 -07:00
parent 11cb1481a9
commit 929cc7c039

View File

@ -838,7 +838,6 @@ bool CTxMemPool::acceptableInputs(CValidationState &state, CTransaction &tx, boo
COutPoint outpoint = tx.vin[i].prevout; COutPoint outpoint = tx.vin[i].prevout;
if (mapNextTx.count(outpoint)) if (mapNextTx.count(outpoint))
{ {
printf("false2\n");
// Disable replacement feature for now // Disable replacement feature for now
return false; return false;
} }
@ -859,14 +858,12 @@ bool CTxMemPool::acceptableInputs(CValidationState &state, CTransaction &tx, boo
// only helps filling in pfMissingInputs (to determine missing vs spent). // only helps filling in pfMissingInputs (to determine missing vs spent).
BOOST_FOREACH(const CTxIn txin, tx.vin) { BOOST_FOREACH(const CTxIn txin, tx.vin) {
if (!view.HaveCoins(txin.prevout.hash)) { if (!view.HaveCoins(txin.prevout.hash)) {
printf("false4\n");
return false; return false;
} }
} }
// are the actual inputs available? // are the actual inputs available?
if (!tx.HaveInputs(view)) { if (!tx.HaveInputs(view)) {
printf("false5\n");
return state.Invalid(error("CTxMemPool::acceptableInputs() : inputs already spent")); 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. // 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)) if (!tx.CheckInputs(state, view, false, SCRIPT_VERIFY_P2SH | SCRIPT_VERIFY_STRICTENC))
{ {
printf("false8\n");
return error("CTxMemPool::acceptableInputs() : ConnectInputs failed \n"); return error("CTxMemPool::acceptableInputs() : ConnectInputs failed \n");
} }
} }
@ -918,7 +914,6 @@ bool CTxMemPool::acceptable(CValidationState &state, CTransaction &tx, bool fChe
{ {
LOCK(cs); LOCK(cs);
if (mapTx.count(hash)) { if (mapTx.count(hash)) {
printf("false1\n");
return false; return false;
} }
} }
@ -929,7 +924,6 @@ bool CTxMemPool::acceptable(CValidationState &state, CTransaction &tx, bool fChe
COutPoint outpoint = tx.vin[i].prevout; COutPoint outpoint = tx.vin[i].prevout;
if (mapNextTx.count(outpoint)) if (mapNextTx.count(outpoint))
{ {
printf("false2\n");
// Disable replacement feature for now // Disable replacement feature for now
return false; return false;
} }
@ -947,7 +941,6 @@ bool CTxMemPool::acceptable(CValidationState &state, CTransaction &tx, bool fChe
// do we already have it? // do we already have it?
if (view.HaveCoins(hash)){ if (view.HaveCoins(hash)){
printf("false3\n");
return false; return false;
} }
@ -958,14 +951,12 @@ bool CTxMemPool::acceptable(CValidationState &state, CTransaction &tx, bool fChe
if (!view.HaveCoins(txin.prevout.hash)) { if (!view.HaveCoins(txin.prevout.hash)) {
if (pfMissingInputs) if (pfMissingInputs)
*pfMissingInputs = true; *pfMissingInputs = true;
printf("false4\n");
return false; return false;
} }
} }
// are the actual inputs available? // are the actual inputs available?
if (!tx.HaveInputs(view)) { if (!tx.HaveInputs(view)) {
printf("false5\n");
return state.Invalid(error("CTxMemPool::acceptable() : inputs already spent")); 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 // Check for non-standard pay-to-script-hash in inputs
if (!tx.AreInputsStandard(view) && !fTestNet) { if (!tx.AreInputsStandard(view) && !fTestNet) {
printf("false6\n");
return error("CTxMemPool::acceptable() : nonstandard transaction input"); 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 // Don't accept it if it can't get into a block
int64 txMinFee = tx.GetMinFee(1000, true, GMF_RELAY); int64 txMinFee = tx.GetMinFee(1000, true, GMF_RELAY);
if (fLimitFree && nFees < txMinFee) { if (fLimitFree && nFees < txMinFee) {
printf("false7\n");
return error("CTxMemPool::acceptable() : not enough fees %s, %"PRI64d" < %"PRI64d, return error("CTxMemPool::acceptable() : not enough fees %s, %"PRI64d" < %"PRI64d,
hash.ToString().c_str(), hash.ToString().c_str(),
nFees, txMinFee); 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. // 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)) 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()); 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 badVote = 0;
int foundMasterNodePaymentPrev = 0; int foundMasterNodePaymentPrev = 0;
int foundMasterNodePayment = 0; int foundMasterNodePayment = 0;
int removedMasterNodePayments = 0;
int64 masternodePaymentAmount = vtx[0].GetValueOut()/10; int64 masternodePaymentAmount = vtx[0].GetValueOut()/10;
bool fIsInitialDownload = IsInitialBlockDownload();
if (pindexPrev != NULL && fCheckVotes){ if (pindexPrev != NULL && fCheckVotes && !fIsInitialDownload){
CBlock blockLast; CBlock blockLast;
if(blockLast.ReadFromDisk(pindexPrev)){ if(blockLast.ReadFromDisk(pindexPrev)){
votingRecordsBlockPrev = blockLast.vmn.size(); 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){ if((pindexPrev->nHeight+1) - mv1.GetHeight() > MASTERNODE_PAYMENTS_EXPIRATION){
return state.DoS(100, error("CheckBlock() : Vote too old")); return state.DoS(100, error("CheckBlock() : Vote too old"));
} else if((pindexPrev->nHeight+1) - mv1.GetHeight() == MASTERNODE_PAYMENTS_EXPIRATION){ } else if((pindexPrev->nHeight+1) - mv1.GetHeight() == MASTERNODE_PAYMENTS_EXPIRATION){
votingRecordsBlockPrev--; removedMasterNodePayments++;
} } else if(mv1.GetVotes() == MASTERNODE_PAYMENTS_MIN_VOTES-1 && foundMasterNodePaymentPrev <= MASTERNODE_PAYMENTS_MAX) {
if(mv1.GetVotes() == MASTERNODE_PAYMENTS_MIN_VOTES-1 && foundMasterNodePaymentPrev <= MASTERNODE_PAYMENTS_MAX) {
for (unsigned int i = 1; i < vtx[0].vout.size(); i++) 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) if(vtx[0].vout[i].nValue == masternodePaymentAmount && mv1.GetPubKey() == vtx[0].vout[i].scriptPubKey)
foundMasterNodePayment++; foundMasterNodePayment++;
@ -2664,9 +2652,9 @@ bool CBlock::CheckBlock(CValidationState &state, bool fCheckPOW, bool fCheckMerk
if(foundMasterNodePayment!=foundMasterNodePaymentPrev) if(foundMasterNodePayment!=foundMasterNodePaymentPrev)
return state.DoS(100, error("CheckBlock() : Required masternode payment missing")); 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")); return state.DoS(100, error("CheckBlock() : Missing masternode votes"));
if(matchingVoteRecords+foundMasterNodePayment>MASTERNODE_PAYMENTS_EXPIRATION) if(matchingVoteRecords+foundMasterNodePayment>MASTERNODE_PAYMENTS_EXPIRATION)
return state.DoS(100, error("CheckBlock() : Too many vote records found")); 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) { if (pfrom->nVersion != darkSendPool.MIN_PEER_PROTO_VERSION) {
return false; return false;
} }
bool fIsInitialDownload = IsInitialBlockDownload();
if(fIsInitialDownload) return true;
CTxIn vin; CTxIn vin;
CService addr; CService addr;
CPubKey pubkey; CPubKey pubkey;