From d9ace8abe804a4134e5e77a0f9f82a52ea339762 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Tue, 23 Jul 2013 17:46:05 +0200 Subject: [PATCH 1/2] Don't use checkpoints and accept nonstd txn on -regtest --- src/checkpoints.cpp | 17 +++++++++++++++-- src/main.cpp | 6 +++--- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/checkpoints.cpp b/src/checkpoints.cpp index ba29e2463..0716cfca3 100644 --- a/src/checkpoints.cpp +++ b/src/checkpoints.cpp @@ -67,11 +67,24 @@ namespace Checkpoints 300 }; + static MapCheckpoints mapCheckpointsRegtest = + boost::assign::map_list_of + ( 0, uint256("0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206")) + ; + static const CCheckpointData dataRegtest = { + &mapCheckpointsRegtest, + 0, + 0, + 0 + }; + const CCheckpointData &Checkpoints() { - if (TestNet()) + if (Params().NetworkID() == CChainParams::TESTNET) return dataTestnet; - else + else if (Params().NetworkID() == CChainParams::MAIN) return data; + else + return dataRegtest; } bool CheckBlock(int nHeight, const uint256& hash) diff --git a/src/main.cpp b/src/main.cpp index d35891440..881580a85 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -810,9 +810,9 @@ bool CTxMemPool::accept(CValidationState &state, CTransaction &tx, bool fLimitFr if ((int64)tx.nLockTime > std::numeric_limits::max()) return error("CTxMemPool::accept() : not accepting nLockTime beyond 2038 yet"); - // Rather not work on nonstandard transactions (unless -testnet) + // Rather not work on nonstandard transactions (unless -testnet/-regtest) string reason; - if (!TestNet() && !IsStandardTx(tx, reason)) + if (Params().NetworkID() == CChainParams::MAIN && !IsStandardTx(tx, reason)) return error("CTxMemPool::accept() : nonstandard transaction: %s", reason.c_str()); @@ -888,7 +888,7 @@ bool CTxMemPool::accept(CValidationState &state, CTransaction &tx, bool fLimitFr } // Check for non-standard pay-to-script-hash in inputs - if (!TestNet() && !AreInputsStandard(tx, view)) + if (Params().NetworkID() == CChainParams::MAIN && !AreInputsStandard(tx, view)) return error("CTxMemPool::accept() : nonstandard transaction input"); // Note: if you modify this code to accept non-standard transactions, then From 9bf2a4aba2c22dc451ce000f7ef081b3d3562b84 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Tue, 23 Jul 2013 17:51:28 +0200 Subject: [PATCH 2/2] Fix multi-block reorg transaction resurrection --- src/main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 881580a85..c8b4876c3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1938,7 +1938,7 @@ bool SetBestChain(CValidationState &state, CBlockIndex* pindexNew) } // Disconnect shorter branch - vector vResurrect; + list vResurrect; BOOST_FOREACH(CBlockIndex* pindex, vDisconnect) { CBlock block; if (!ReadBlockFromDisk(block, pindex)) @@ -1952,9 +1952,9 @@ bool SetBestChain(CValidationState &state, CBlockIndex* pindexNew) // Queue memory transactions to resurrect. // We only do this for blocks after the last checkpoint (reorganisation before that // point should only happen with -reindex/-loadblock, or a misbehaving peer. - BOOST_FOREACH(const CTransaction& tx, block.vtx) + BOOST_REVERSE_FOREACH(const CTransaction& tx, block.vtx) if (!tx.IsCoinBase() && pindex->nHeight > Checkpoints::GetTotalBlocksEstimate()) - vResurrect.push_back(tx); + vResurrect.push_front(tx); } // Connect longer branch