From 63a9f52633c8ceeded1b40b69c723a8ce82c7196 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 21 Oct 2016 16:08:37 -0300 Subject: [PATCH] test --- src/coins.cpp | 17 +++++++++++------ src/coins.h | 2 +- src/main.cpp | 2 +- src/miner.cpp | 2 +- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/coins.cpp b/src/coins.cpp index 19283ebb8..0fb9d4611 100644 --- a/src/coins.cpp +++ b/src/coins.cpp @@ -406,16 +406,21 @@ uint32_t komodo_txtime(uint256 hash) return(tx.nLockTime); } -CAmount CCoinsViewCache::GetValueIn(const CTransaction& tx) const +CAmount CCoinsViewCache::GetValueIn(const CTransaction& tx,uint32_t blocktime) const { - if (tx.IsCoinBase()) + uint32_t timestamp,minutes; + if ( tx.IsCoinBase() != 0 ) return 0; - - CAmount nResult = 0; + CAmount value,nResult = 0; for (unsigned int i = 0; i < tx.vin.size(); i++) { - //fprintf(stderr,"GetValueIn i.%d time.%u\n",i,komodo_txtime(tx.vin[i].prevout.hash)); - nResult += GetOutputFor(tx.vin[i]).nValue; + value = GetOutputFor(tx.vin[i]).nValue; + nResult += value; + if ( (timestamp= komodo_txtime(tx.vin[i].prevout.hash)) != 0 && timestamp < blocktime-3600*24*7 && value >= COIN ) + { + minutes = (blocktime - timestamp) / 60; + fprintf(stderr,"GetValueIn %lld i.%d time.%u minutes.%d\n",(long long)value,i,timestamp,minutes); + } } nResult += tx.GetJoinSplitValueIn(); diff --git a/src/coins.h b/src/coins.h index 7f1fc6124..93fe1d965 100644 --- a/src/coins.h +++ b/src/coins.h @@ -510,7 +510,7 @@ public: * @param[in] tx transaction for which we are checking input total * @return Sum of value of all inputs (scriptSigs) */ - CAmount GetValueIn(const CTransaction& tx) const; + CAmount GetValueIn(const CTransaction& tx,uint32_t blocktime) const; //! Check whether all prevouts of the transaction are present in the UTXO set represented by this view bool HaveInputs(const CTransaction& tx) const; diff --git a/src/main.cpp b/src/main.cpp index bf7952d88..290f64ac6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2153,7 +2153,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin return state.DoS(100, error("ConnectBlock(): too many sigops"), REJECT_INVALID, "bad-blk-sigops"); - nFees += view.GetValueIn(tx)-tx.GetValueOut(); + nFees += view.GetValueIn(tx,pindex->nTime)-tx.GetValueOut(); std::vector vChecks; if (!ContextualCheckInputs(tx, state, view, fScriptChecks, flags, false, chainparams.GetConsensus(), nScriptCheckThreads ? &vChecks : NULL)) diff --git a/src/miner.cpp b/src/miner.cpp index c65dcff41..faac50bc4 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -275,7 +275,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) if (!view.HaveInputs(tx)) continue; - CAmount nTxFees = view.GetValueIn(tx)-tx.GetValueOut(); + CAmount nTxFees = view.GetValueIn(tx,pblock->nTime)-tx.GetValueOut(); nTxSigOps += GetP2SHSigOpCount(tx, view); if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS)