Make CBlockIndex* returned by GetDepthInMainChain const.
Make the CBlockIndex* (optionally) returned by GetDepthInMainChain const. This prevents accidental modification. The result is for reading its properties rather than modifying it.
This commit is contained in:
parent
3552d4b859
commit
a31e8bad53
2 changed files with 6 additions and 6 deletions
|
@ -2298,7 +2298,7 @@ int CMerkleTx::SetMerkleBranch(const CBlock& block)
|
||||||
return chainActive.Height() - pindex->nHeight + 1;
|
return chainActive.Height() - pindex->nHeight + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CMerkleTx::GetDepthInMainChainINTERNAL(CBlockIndex* &pindexRet) const
|
int CMerkleTx::GetDepthInMainChainINTERNAL(const CBlockIndex* &pindexRet) const
|
||||||
{
|
{
|
||||||
if (hashBlock == 0 || nIndex == -1)
|
if (hashBlock == 0 || nIndex == -1)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2324,7 +2324,7 @@ int CMerkleTx::GetDepthInMainChainINTERNAL(CBlockIndex* &pindexRet) const
|
||||||
return chainActive.Height() - pindex->nHeight + 1;
|
return chainActive.Height() - pindex->nHeight + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CMerkleTx::GetDepthInMainChain(CBlockIndex* &pindexRet) const
|
int CMerkleTx::GetDepthInMainChain(const CBlockIndex* &pindexRet) const
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_main);
|
AssertLockHeld(cs_main);
|
||||||
int nResult = GetDepthInMainChainINTERNAL(pindexRet);
|
int nResult = GetDepthInMainChainINTERNAL(pindexRet);
|
||||||
|
|
|
@ -474,7 +474,7 @@ struct COutputEntry
|
||||||
class CMerkleTx : public CTransaction
|
class CMerkleTx : public CTransaction
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
int GetDepthInMainChainINTERNAL(CBlockIndex* &pindexRet) const;
|
int GetDepthInMainChainINTERNAL(const CBlockIndex* &pindexRet) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
uint256 hashBlock;
|
uint256 hashBlock;
|
||||||
|
@ -519,9 +519,9 @@ public:
|
||||||
// -1 : not in blockchain, and not in memory pool (conflicted transaction)
|
// -1 : not in blockchain, and not in memory pool (conflicted transaction)
|
||||||
// 0 : in memory pool, waiting to be included in a block
|
// 0 : in memory pool, waiting to be included in a block
|
||||||
// >=1 : this many blocks deep in the main chain
|
// >=1 : this many blocks deep in the main chain
|
||||||
int GetDepthInMainChain(CBlockIndex* &pindexRet) const;
|
int GetDepthInMainChain(const CBlockIndex* &pindexRet) const;
|
||||||
int GetDepthInMainChain() const { CBlockIndex *pindexRet; return GetDepthInMainChain(pindexRet); }
|
int GetDepthInMainChain() const { const CBlockIndex *pindexRet; return GetDepthInMainChain(pindexRet); }
|
||||||
bool IsInMainChain() const { CBlockIndex *pindexRet; return GetDepthInMainChainINTERNAL(pindexRet) > 0; }
|
bool IsInMainChain() const { const CBlockIndex *pindexRet; return GetDepthInMainChainINTERNAL(pindexRet) > 0; }
|
||||||
int GetBlocksToMaturity() const;
|
int GetBlocksToMaturity() const;
|
||||||
bool AcceptToMemoryPool(bool fLimitFree=true, bool fRejectInsaneFee=true);
|
bool AcceptToMemoryPool(bool fLimitFree=true, bool fRejectInsaneFee=true);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue