message: IsInitialBlockDownload: usually avoid locking
  Optimistically test the latch bool before taking the lock.
  For all IsInitialBlockDownload calls after the first to return false,
  this avoids the need to lock cs_main.
  Coming from btc@f0fdda0181e1b05b66541bf235c6702c41664170
diff: @@ -1530,17 +1530,22 @@ int64_t GetMasternodePayment()
  bool IsInitialBlockDownload()
  {
  + // Once this function has returned false, it must remain false.
  + static std::atomic<bool> latchToFalse{false};
  + // Optimization: pre-test latch before taking the lock.
  + if (latchToFalse.load(std::memory_order_relaxed))
  + return false;
  +
  LOCK(cs_main);
  + if (latchToFalse.load(std::memory_order_relaxed))
  + return false;
  const int chainHeight = chainActive.Height();
  if (fImporting || fReindex || fVerifyingBlocks || chainHeight < Checkpoints::GetTotalBlocksEstimate())
  return true;
  - static bool lockIBDState = false;
  - if (lockIBDState)
  - return false;
  bool state = (chainHeight < pindexBestHeader->nHeight - 24 * 6 ||
  pindexBestHeader->GetBlockTime() < GetTime() - nMaxTipAge);
  if (!state)
  - lockIBDState = true;
  + latchToFalse.store(true, std::memory_order_relaxed);
  return state;
  }
  