message: [Spork] Guard chainActive.Tip() and chainActive.Height() methods call.
diff: @@ -75,7 +75,15 @@ void CSporkManager::LoadSporksFromDB()
  void CSporkManager::ProcessSpork(CNode* pfrom, std::string& strCommand, CDataStream& vRecv)
  {
  - if (fLiteMode || chainActive.Tip() == nullptr) return; // disable all obfuscation/masternode related functionality
  + if (fLiteMode) return; // disable all obfuscation/masternode related functionality
  +
  + int nChainHeight = 0;
  + {
  + LOCK(cs_main);
  + if (chainActive.Tip() == nullptr)
  + return;
  + nChainHeight = chainActive.Height();
  + }
  if (strCommand == "spork") {
  @@ -96,13 +104,8 @@ void CSporkManager::ProcessSpork(CNode* pfrom, std::string& strCommand, CDataStr
  // reject old signatures 600 blocks after hard-fork
  if (spork.nMessVersion != MessageVersion::MESS_VER_HASH) {
  - int nHeight;
  - {
  - LOCK(cs_main);
  - nHeight = chainActive.Height();
  - }
  - if (Params().NewSigsActive(nHeight - 600)) {
  - LogPrintf("%s : nMessVersion=%d not accepted anymore at block %d", __func__, spork.nMessVersion, nHeight);
  + if (Params().NewSigsActive(nChainHeight - 600)) {
  + LogPrintf("%s : nMessVersion=%d not accepted anymore at block %d\n", __func__, spork.nMessVersion, nChainHeight);
  return;
  }
  }
  @@ -115,19 +118,19 @@ void CSporkManager::ProcessSpork(CNode* pfrom, std::string& strCommand, CDataStr
  // spork is active
  if (mapSporksActive[spork.nSporkID].nTimeSigned >= spork.nTimeSigned) {
  // spork in memory has been signed more recently
  - if (fDebug) LogPrintf("%s : seen %s block %d \n", __func__, hash.ToString(), chainActive.Tip()->nHeight);
  + if (fDebug) LogPrintf("%s : seen %s block %d \n", __func__, hash.ToString(), nChainHeight);
  return;
  } else {
  // update active spork
  - if (fDebug) LogPrintf("%s : got updated spork %s block %d \n", __func__, hash.ToString(), chainActive.Tip()->nHeight);
  + if (fDebug) LogPrintf("%s : got updated spork %s block %d \n", __func__, hash.ToString(), nChainHeight);
  }
  } else {
  // spork is not active
  - if (fDebug) LogPrintf("%s : got new spork %s block %d \n", __func__, hash.ToString(), chainActive.Tip()->nHeight);
  + if (fDebug) LogPrintf("%s : got new spork %s block %d \n", __func__, hash.ToString(), nChainHeight);
  }
  }
  - LogPrintf("%s : new %s ID %d Time %d bestHeight %d\n", __func__, hash.ToString(), spork.nSporkID, spork.nValue, chainActive.Tip()->nHeight);
  + LogPrintf("%s : new %s ID %d Time %d bestHeight %d\n", __func__, hash.ToString(), spork.nSporkID, spork.nValue, nChainHeight);
  const bool fRequireNew = spork.nTimeSigned >= Params().NewSporkStart();
  bool fValidSig = spork.CheckSignature();
  