Fail on get_chainactive before lock if checks fail

This commit is contained in:
Michael Toutonghi
2018-08-10 17:21:41 -07:00
parent a491b97f4e
commit 3c40a9a667

View File

@@ -813,11 +813,13 @@ int32_t waitForPeers(const CChainParams &chainparams)
#ifdef ENABLE_WALLET
CBlockIndex *get_chainactive(int32_t height)
{
LOCK(cs_main);
if ( chainActive.Tip() != 0 )
if ( chainActive.LastTip() != 0 )
{
if ( height <= chainActive.Tip()->nHeight )
if ( height <= chainActive.LastTip()->nHeight )
{
LOCK(cs_main);
return(chainActive[height]);
}
// else fprintf(stderr,"get_chainactive height %d > active.%d\n",height,chainActive.Tip()->nHeight);
}
//fprintf(stderr,"get_chainactive null chainActive.Tip() height %d\n",height);