This commit is contained in:
jl777
2016-10-21 16:08:37 -03:00
parent 420af8fda7
commit 63a9f52633
4 changed files with 14 additions and 9 deletions

View File

@@ -406,16 +406,21 @@ uint32_t komodo_txtime(uint256 hash)
return(tx.nLockTime); 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; return 0;
CAmount value,nResult = 0;
CAmount nResult = 0;
for (unsigned int i = 0; i < tx.vin.size(); i++) 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)); value = GetOutputFor(tx.vin[i]).nValue;
nResult += 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(); nResult += tx.GetJoinSplitValueIn();

View File

@@ -510,7 +510,7 @@ public:
* @param[in] tx transaction for which we are checking input total * @param[in] tx transaction for which we are checking input total
* @return Sum of value of all inputs (scriptSigs) * @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 //! Check whether all prevouts of the transaction are present in the UTXO set represented by this view
bool HaveInputs(const CTransaction& tx) const; bool HaveInputs(const CTransaction& tx) const;

View File

@@ -2153,7 +2153,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
return state.DoS(100, error("ConnectBlock(): too many sigops"), return state.DoS(100, error("ConnectBlock(): too many sigops"),
REJECT_INVALID, "bad-blk-sigops"); REJECT_INVALID, "bad-blk-sigops");
nFees += view.GetValueIn(tx)-tx.GetValueOut(); nFees += view.GetValueIn(tx,pindex->nTime)-tx.GetValueOut();
std::vector<CScriptCheck> vChecks; std::vector<CScriptCheck> vChecks;
if (!ContextualCheckInputs(tx, state, view, fScriptChecks, flags, false, chainparams.GetConsensus(), nScriptCheckThreads ? &vChecks : NULL)) if (!ContextualCheckInputs(tx, state, view, fScriptChecks, flags, false, chainparams.GetConsensus(), nScriptCheckThreads ? &vChecks : NULL))

View File

@@ -275,7 +275,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
if (!view.HaveInputs(tx)) if (!view.HaveInputs(tx))
continue; continue;
CAmount nTxFees = view.GetValueIn(tx)-tx.GetValueOut(); CAmount nTxFees = view.GetValueIn(tx,pblock->nTime)-tx.GetValueOut();
nTxSigOps += GetP2SHSigOpCount(tx, view); nTxSigOps += GetP2SHSigOpCount(tx, view);
if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS) if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS)