message: miner: decouple SolveProofOfStake flow from CreateNewBlock function.
diff: @@ -157,6 +157,23 @@ bool CheckForDuplicatedSerials(const CTransaction& tx, const Consensus::Params&
  return true;
  }
  +bool SolveProofOfStake(CBlock* pblock, CBlockIndex* pindexPrev, CWallet* pwallet)
  +{
  + boost::this_thread::interruption_point();
  + pblock->nBits = GetNextWorkRequired(pindexPrev, pblock);
  + CMutableTransaction txCoinStake;
  + int64_t nTxNewTime = 0;
  + if (!pwallet->CreateCoinStake(*pwallet, pindexPrev, pblock->nBits, txCoinStake, nTxNewTime)) {
  + LogPrint(BCLog::STAKING, "%s : stake not found\n", __func__);
  + return false;
  + }
  + // Stake found
  + pblock->nTime = nTxNewTime;
  + pblock->vtx[0].vout[0].SetEmpty();
  + pblock->vtx.emplace_back(CTransaction(txCoinStake));
  + return true;
  +}
  +
  CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn, CWallet* pwallet, bool fProofOfStake)
  {
  // Create new block
  @@ -191,18 +208,10 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn, CWallet* pwallet,
  pblocktemplate->vTxSigOps.push_back(-1); // updated at end
  if (fProofOfStake) {
  - boost::this_thread::interruption_point();
  - pblock->nBits = GetNextWorkRequired(pindexPrev, pblock);
  - CMutableTransaction txCoinStake;
  - int64_t nTxNewTime = 0;
  - if (!pwallet->CreateCoinStake(*pwallet, pindexPrev, pblock->nBits, txCoinStake, nTxNewTime)) {
  - LogPrint(BCLog::STAKING, "%s : stake not found\n", __func__);
  + // Try to find a coinstake who solves it.
  + if(!SolveProofOfStake(pblock, pindexPrev, pwallet)) {
  return nullptr;
  }
  - // Stake found
  - pblock->nTime = nTxNewTime;
  - pblock->vtx[0].vout[0].SetEmpty();
  - pblock->vtx.push_back(CTransaction(txCoinStake));
  }
  // Largest block you're willing to create:
  