From 85392ed8bbcb6bd2d199f9f78b8657b719401404 Mon Sep 17 00:00:00 2001 From: Ross Nicoll Date: Sun, 20 Apr 2014 12:12:03 +0100 Subject: Added GetHeightInMainChain() method. Corrected call to GetDepthInMainChain() with GetHeightInMainChain() when checking coin maturity. --- src/main.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index dac145148..3210a7875 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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()); -- cgit v1.2.3