aboutsummaryrefslogtreecommitdiff
path: root/src/validation.cpp
diff options
context:
space:
mode:
authorRoss Nicoll <[email protected]>2018-02-11 21:00:50 +0000
committerRoss Nicoll <[email protected]>2018-09-19 22:11:47 +0100
commit9c3a11b2488f3e01e6763bc1217598a4d1c69bde (patch)
treeed6b54c5b71a4543a32968dc5b1d391bfe59dfed /src/validation.cpp
parentInsert Dogecoin testnet merkle tree root value (#1469) (diff)
downloaddiscoin-9c3a11b2488f3e01e6763bc1217598a4d1c69bde.tar.xz
discoin-9c3a11b2488f3e01e6763bc1217598a4d1c69bde.zip
Clean up RPC tests (#1465)
* Enable full block tests * Fix invalidblocktest * Move watch only address funding to immediately before it's used, so node 0 doesn't spend the output before it checks it later. * Fix `fundrawtransaction` tests and sanitize fee calculation at the same time * Correct resolution of chain parameters when validating tx inputs, especially from previous coinbase transactions * Set block versions on full block tests so that the generated blocks are AuxPoW compatible
Diffstat (limited to 'src/validation.cpp')
-rw-r--r--src/validation.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/validation.cpp b/src/validation.cpp
index 1f29a9b6b..c5041cea9 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -1396,7 +1396,7 @@ int GetSpendHeight(const CCoinsViewCache& inputs)
}
namespace Consensus {
-bool CheckTxInputs(const CTransaction& tx, CValidationState& state, const CCoinsViewCache& inputs, int nSpendHeight)
+bool CheckTxInputs(const CChainParams& params, const CTransaction& tx, CValidationState& state, const CCoinsViewCache& inputs, int nSpendHeight)
{
// This doesn't trigger the DoS code on purpose; if it did, it would make it easier
// for an attacker to attempt to split the network.
@@ -1414,7 +1414,7 @@ bool CheckTxInputs(const CTransaction& tx, CValidationState& state, const CCoins
// If prev is coinbase, check that it's matured
if (coins->IsCoinBase()) {
// Dogecoin: Switch maturity at depth 145,000
- int nCoinbaseMaturity = Params().GetConsensus(coins->nHeight)->nCoinbaseMaturity;
+ int nCoinbaseMaturity = params.GetConsensus(coins->nHeight).nCoinbaseMaturity;
if (nSpendHeight - coins->nHeight < nCoinbaseMaturity)
return state.Invalid(false,
REJECT_INVALID, "bad-txns-premature-spend-of-coinbase",
@@ -1447,7 +1447,7 @@ bool CheckInputs(const CTransaction& tx, CValidationState &state, const CCoinsVi
{
if (!tx.IsCoinBase())
{
- if (!Consensus::CheckTxInputs(tx, state, inputs, GetSpendHeight(inputs)))
+ if (!Consensus::CheckTxInputs(Params(), tx, state, inputs, GetSpendHeight(inputs)))
return false;
if (pvChecks)
@@ -2459,7 +2459,7 @@ static bool ActivateBestChainStep(CValidationState& state, const CChainParams& c
}
if (fBlocksDisconnected) {
- mempool.removeForReorg(pcoinsTip, chainActive.Tip()->nHeight + 1, STANDARD_LOCKTIME_VERIFY_FLAGS);
+ mempool.removeForReorg(pcoinsTip, chainActive.Height() + 1, STANDARD_LOCKTIME_VERIFY_FLAGS);
LimitMempoolSize(mempool, GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000, GetArg("-mempoolexpiry", DEFAULT_MEMPOOL_EXPIRY) * 60 * 60);
}
mempool.check(pcoinsTip);
@@ -2628,7 +2628,7 @@ bool InvalidateBlock(CValidationState& state, const CChainParams& chainparams, C
// ActivateBestChain considers blocks already in chainActive
// unconditionally valid already, so force disconnect away from it.
if (!DisconnectTip(state, chainparams)) {
- mempool.removeForReorg(pcoinsTip, chainActive.Tip()->nHeight + 1, STANDARD_LOCKTIME_VERIFY_FLAGS);
+ mempool.removeForReorg(pcoinsTip, chainActive.Height() + 1, STANDARD_LOCKTIME_VERIFY_FLAGS);
return false;
}
}
@@ -2646,7 +2646,7 @@ bool InvalidateBlock(CValidationState& state, const CChainParams& chainparams, C
}
InvalidChainFound(pindex);
- mempool.removeForReorg(pcoinsTip, chainActive.Tip()->nHeight + 1, STANDARD_LOCKTIME_VERIFY_FLAGS);
+ mempool.removeForReorg(pcoinsTip, chainActive.Height() + 1, STANDARD_LOCKTIME_VERIFY_FLAGS);
uiInterface.NotifyBlockTip(IsInitialBlockDownload(), pindex->pprev);
return true;
}
@@ -3426,7 +3426,7 @@ void FindFilesToPruneManual(std::set<int>& setFilesToPrune, int nManualPruneHeig
return;
// last block to prune is the lesser of (user-specified height, MIN_BLOCKS_TO_KEEP from the tip)
- unsigned int nLastBlockWeCanPrune = std::min((unsigned)nManualPruneHeight, chainActive.Tip()->nHeight - MIN_BLOCKS_TO_KEEP);
+ unsigned int nLastBlockWeCanPrune = std::min((unsigned)nManualPruneHeight, chainActive.Height() - MIN_BLOCKS_TO_KEEP);
int count=0;
for (int fileNumber = 0; fileNumber < nLastBlockFile; fileNumber++) {
if (vinfoBlockFile[fileNumber].nSize == 0 || vinfoBlockFile[fileNumber].nHeightLast > nLastBlockWeCanPrune)
@@ -3452,11 +3452,11 @@ void FindFilesToPrune(std::set<int>& setFilesToPrune, uint64_t nPruneAfterHeight
if (chainActive.Tip() == NULL || nPruneTarget == 0) {
return;
}
- if ((uint64_t)chainActive.Tip()->nHeight <= nPruneAfterHeight) {
+ if ((uint64_t)chainActive.Height() <= nPruneAfterHeight) {
return;
}
- unsigned int nLastBlockWeCanPrune = chainActive.Tip()->nHeight - MIN_BLOCKS_TO_KEEP;
+ unsigned int nLastBlockWeCanPrune = chainActive.Height() - MIN_BLOCKS_TO_KEEP;
uint64_t nCurrentUsage = CalculateCurrentUsage();
// We don't check to prune until after we've allocated new space for files
// So we should leave a buffer under our target to account for another allocation