add blocks that have pegins rejected to the reconsider queue

This commit is contained in:
Gregory Sanders 2017-09-15 14:46:02 -04:00
parent 0b9c5eb0e0
commit 6bad4e9d75
2 changed files with 22 additions and 2 deletions

View file

@ -17,6 +17,7 @@ static const unsigned char REJECT_NONSTANDARD = 0x40;
static const unsigned char REJECT_DUST = 0x41; static const unsigned char REJECT_DUST = 0x41;
static const unsigned char REJECT_INSUFFICIENTFEE = 0x42; static const unsigned char REJECT_INSUFFICIENTFEE = 0x42;
static const unsigned char REJECT_CHECKPOINT = 0x43; static const unsigned char REJECT_CHECKPOINT = 0x43;
static const unsigned char REJECT_PEGIN = 0x44;
/** Capture information about block/transaction validation */ /** Capture information about block/transaction validation */
class CValidationState { class CValidationState {

View file

@ -1834,7 +1834,7 @@ bool CheckTxInputs(const CTransaction& tx, CValidationState& state, const CCoins
if (tx.vin[i].m_is_pegin) { if (tx.vin[i].m_is_pegin) {
// Check existence and validity of pegin witness // Check existence and validity of pegin witness
if (tx.wit.vtxinwit.size() <= i || !IsValidPeginWitness(tx.wit.vtxinwit[i].m_pegin_witness, prevout)) { if (tx.wit.vtxinwit.size() <= i || !IsValidPeginWitness(tx.wit.vtxinwit[i].m_pegin_witness, prevout)) {
return state.DoS(0, false, REJECT_INVALID, "bad-pegin-witness", true); return state.DoS(0, false, REJECT_PEGIN, "bad-pegin-witness", true);
} }
std::pair<uint256, COutPoint> pegin = std::make_pair(uint256(tx.wit.vtxinwit[i].m_pegin_witness.stack[2]), prevout); std::pair<uint256, COutPoint> pegin = std::make_pair(uint256(tx.wit.vtxinwit[i].m_pegin_witness.stack[2]), prevout);
if (inputs.IsWithdrawSpent(pegin)) { if (inputs.IsWithdrawSpent(pegin)) {
@ -3035,7 +3035,26 @@ bool static ConnectTip(CValidationState& state, const CChainParams& chainparams,
if (!rv) { if (!rv) {
if (state.IsInvalid()) { if (state.IsInvalid()) {
InvalidBlockFound(pindexNew, state); InvalidBlockFound(pindexNew, state);
} //Possibly result of RPC to bitcoind failure
//or unseen Bitcoin blocks.
if (state.GetRejectCode() == REJECT_PEGIN) {
//Write queue of invalid blocks that
//must be cleared to continue operation
std::vector<uint256> vinvalidBlocks;
pblocktree->ReadInvalidBlockQueue(vinvalidBlocks);
bool blockAlreadyInvalid = false;
BOOST_FOREACH(uint256& hash, vinvalidBlocks) {
if (hash == pblock->GetHash()) {
blockAlreadyInvalid = true;
break;
}
}
if (!blockAlreadyInvalid) {
vinvalidBlocks.push_back(pblock->GetHash());
pblocktree->WriteInvalidBlockQueue(vinvalidBlocks);
}
}
}
return error("ConnectTip(): ConnectBlock %s failed", pindexNew->GetBlockHash().ToString()); return error("ConnectTip(): ConnectBlock %s failed", pindexNew->GetBlockHash().ToString());
} }