add a couple sanity checks to GetLastValidBlockHash

This commit is contained in:
Evan Duffield 2015-02-02 12:27:07 -07:00
parent 1f828f45ec
commit 6b0c7f3c4f

View File

@ -1323,7 +1323,8 @@ bool CDarkSendPool::GetLastValidBlockHash(uint256& hash, int mod, int nBlockHeig
const CBlockIndex *BlockLastSolved = chainActive.Tip();
const CBlockIndex *BlockReading = chainActive.Tip();
if (BlockLastSolved == NULL || BlockLastSolved->nHeight == 0) { return false; }
if (chainActive.Tip() == NULL) return false;
if (BlockLastSolved == NULL || BlockLastSolved->nHeight == 0 || (chainActive.Tip()->nHeight+1 < nBlockHeight) return false;
int nBlocksAgo = 0;
if(nBlockHeight > 0) nBlocksAgo = (chainActive.Tip()->nHeight+1)-nBlockHeight;