Added GetHeightInMainChain() method.

Corrected call to GetDepthInMainChain() with GetHeightInMainChain() when checking coin maturity.
This commit is contained in:
Ross Nicoll 2014-04-20 12:12:03 +01:00 committed by Patrick Lodder
parent e1ce43df71
commit 85392ed8bb
2 changed files with 8 additions and 1 deletions

View file

@ -932,12 +932,17 @@ int CMerkleTx::GetDepthInMainChain(CBlockIndex* &pindexRet) const
return nResult;
}
int CMerkleTx::GetHeightInMainChain(CBlockIndex* &pindexRet) const
{
return chainActive.Height() - GetDepthInMainChain(pindexRet) + 1;
}
int CMerkleTx::GetBlocksToMaturity() const
{
if (!IsCoinBase())
return 0;
if(GetDepthInMainChain() >= COINBASE_MATURITY_SWITCH)
if(GetHeightInMainChain() >= COINBASE_MATURITY_SWITCH)
return max(0, (COINBASE_MATURITY_NEW+20) - GetDepthInMainChain());
else
return max(0, (COINBASE_MATURITY+20) - GetDepthInMainChain());

View file

@ -476,6 +476,8 @@ public:
// >=1 : this many blocks deep in the main chain
int GetDepthInMainChain(CBlockIndex* &pindexRet) const;
int GetDepthInMainChain() const { CBlockIndex *pindexRet; return GetDepthInMainChain(pindexRet); }
int GetHeightInMainChain(CBlockIndex* &pindexRet) const;
int GetHeightInMainChain() const { CBlockIndex *pindexRet; return GetHeightInMainChain(pindexRet); }
bool IsInMainChain() const { CBlockIndex *pindexRet; return GetDepthInMainChainINTERNAL(pindexRet) > 0; }
int GetBlocksToMaturity() const;
bool AcceptToMemoryPool(bool fLimitFree=true);