Completely remove coinage

This commit is contained in:
lateminer
2018-10-12 00:04:41 +03:00
parent 4fc1725b73
commit d452787a2c
3 changed files with 23 additions and 102 deletions

View File

@@ -3273,63 +3273,6 @@ bool ReconsiderBlock(CValidationState& state, CBlockIndex *pindex) {
return true;
}
// ppcoin: total coin age spent in transaction, in the unit of coin-days.
// Only those coins meeting minimum age requirement counts. As those
// transactions not in main chain are not currently indexed so we
// might not find out about their coin age. Older transactions are
// guaranteed to be in main chain by sync-checkpoint. This rule is
// introduced to help nodes establish a consistent view of the coin
// age (trust score) of competing branches.
bool GetCoinAge(const CTransaction& tx, CBlockTreeDB& txdb, const CBlockIndex* pindexPrev, uint64_t& nCoinAge)
{
arith_uint256 bnCentSecond = 0; // coin age in the unit of cent-seconds
nCoinAge = 0;
if (tx.IsCoinBase())
return true;
BOOST_FOREACH(const CTxIn& txin, tx.vin)
{
// First try finding the previous transaction in database
CTransaction txPrev;
CDiskTxPos txindex;
if (!ReadFromDisk(txPrev, txindex, *pblocktree, txin.prevout))
continue; // previous transaction not in main chain
if (tx.nTime < txPrev.nTime)
return false; // Transaction timestamp violation
if (Params().GetConsensus().IsProtocolV3(tx.nTime))
{
int nSpendDepth;
if (IsConfirmedInNPrevBlocks(txindex, pindexPrev, Params().GetConsensus().nStakeMinConfirmations - 1, nSpendDepth))
{
LogPrint("coinage", "coin age skip nSpendDepth=%d\n", nSpendDepth + 1);
continue; // only count coins meeting min confirmations requirement
}
}
else
{
// Read block header
CBlock block;
const CDiskBlockPos& pos = CDiskBlockPos(txindex.nFile, txindex.nPos);
if (!ReadBlockFromDisk(block, pos, Params().GetConsensus()))
return false; // unable to read block of previous transaction
if (block.GetBlockTime() + Params().GetConsensus().nStakeMinAge > tx.nTime)
continue; // only count coins meeting min age requirement
}
int64_t nValueIn = txPrev.vout[txin.prevout.n].nValue;
bnCentSecond += arith_uint256(nValueIn) * (tx.nTime-txPrev.nTime) / CENT;
LogPrint("coinage", "coin age nValueIn=%d nTimeDiff=%d bnCentSecond=%s\n", nValueIn, tx.nTime - txPrev.nTime, bnCentSecond.ToString());
}
arith_uint256 bnCoinDay = bnCentSecond * CENT / COIN / (24 * 60 * 60);
LogPrint("coinage", "coin age bnCoinDay=%s\n", bnCoinDay.ToString());
nCoinAge = bnCoinDay.GetLow64();
return true;
}
static CBlockIndex* AddToBlockIndex(const CBlockHeader& block)
{
// Check for duplicate