Skip to content

Commit

Permalink
Fix up CBlock::GetCoinAge
Browse files Browse the repository at this point in the history
  • Loading branch information
akyo8 committed Mar 1, 2021
1 parent c30332f commit 8e5b78c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 20 additions & 0 deletions src/primitives/block.cpp
Expand Up @@ -15,6 +15,26 @@ uint256 CBlockHeader::GetHash() const
//return SerializeHash(*this);
}

// ppcoin: total coin age spent in block, in the unit of coin-days.
bool CBlock::GetCoinAge(uint64_t& nCoinAge) const
{
nCoinAge = 0;
for (const CTransactionRef tx : vtx) {
{
uint64_t nTxCoinAge;
if (tx->GetCoinAge(nTxCoinAge))
nCoinAge += nTxCoinAge;
else
return false;
}

if (nCoinAge == 0) // block coin age minimum 1 coin-day
nCoinAge = 1;
//if (fDebug && GetBoolArg("-printcoinage"))
// printf("block coin age total nCoinDays=%" PRI64d "\n", nCoinAge);
return true;
}

std::string CBlock::ToString() const
{
std::stringstream s;
Expand Down
2 changes: 1 addition & 1 deletion src/primitives/block.h
Expand Up @@ -33,7 +33,7 @@ class CBlockHeader
{
SetNull();
}

bool GetCoinAge(uint64_t& nCoinAge) const;
SERIALIZE_METHODS(CBlockHeader, obj) { READWRITE(obj.nVersion, obj.hashPrevBlock, obj.hashMerkleRoot, obj.nTime, obj.nBits, obj.nNonce); }

void SetNull()
Expand Down

0 comments on commit 8e5b78c

Please sign in to comment.