mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-14 12:43:40 +02:00
add blocks that have pegins rejected to the reconsider queue
This commit is contained in:
parent
0b9c5eb0e0
commit
6bad4e9d75
2 changed files with 22 additions and 2 deletions
|
|
@ -17,6 +17,7 @@ static const unsigned char REJECT_NONSTANDARD = 0x40;
|
|||
static const unsigned char REJECT_DUST = 0x41;
|
||||
static const unsigned char REJECT_INSUFFICIENTFEE = 0x42;
|
||||
static const unsigned char REJECT_CHECKPOINT = 0x43;
|
||||
static const unsigned char REJECT_PEGIN = 0x44;
|
||||
|
||||
/** Capture information about block/transaction validation */
|
||||
class CValidationState {
|
||||
|
|
|
|||
|
|
@ -1834,7 +1834,7 @@ bool CheckTxInputs(const CTransaction& tx, CValidationState& state, const CCoins
|
|||
if (tx.vin[i].m_is_pegin) {
|
||||
// Check existence and validity of pegin witness
|
||||
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);
|
||||
if (inputs.IsWithdrawSpent(pegin)) {
|
||||
|
|
@ -3035,7 +3035,26 @@ bool static ConnectTip(CValidationState& state, const CChainParams& chainparams,
|
|||
if (!rv) {
|
||||
if (state.IsInvalid()) {
|
||||
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());
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue