message: Fix for potential deadlock
  We have to do the lock on cs_main outside of the section
  where we lock mempool.cs.
diff: @@ -284,6 +284,8 @@ bool CXThinBlock::process(CNode* pfrom, int nSizeThinBlock, string strCommand)
  mapPartialTxHash[cheapHash] = (*mi).first;
  }
  }
  +
  + bool fMerkleRootCorrect = true;
  {
  // We don't have to keep the lock on mempool.cs here to do mempool.queryHashes
  // but we take the lock anyway so we don't have to re-lock again later.
  @@ -309,7 +311,6 @@ bool CXThinBlock::process(CNode* pfrom, int nSizeThinBlock, string strCommand)
  }
  mapPartialTxHash[cheapHash] = (*mi).first;
  }
  -
  if (!collision)
  {
  std::vector<uint256> fullTxHashes;
  @@ -320,10 +321,10 @@ bool CXThinBlock::process(CNode* pfrom, int nSizeThinBlock, string strCommand)
  uint256 merkleroot = ComputeMerkleRoot(fullTxHashes, &mutated);
  if (header.hashMerkleRoot != merkleroot)
  {
  - LOCK(cs_main);
  - Misbehaving(pfrom->GetId(), 100);
  - return error("Thinblock merkelroot does not match computed merkleroot, peer=%d", pfrom->GetId());
  + fMerkleRootCorrect = false;
  }
  + else
  + {
  // Look for each transaction in our various pools and buffers.
  // With xThinBlocks the vTxHashes contains only the first 8 bytes of the tx hash.
  @@ -355,8 +356,17 @@ bool CXThinBlock::process(CNode* pfrom, int nSizeThinBlock, string strCommand)
  pfrom->thinBlock.vtx.push_back(tx);
  }
  }
  + }
  } // End locking mempool.cs and cs_xval
  + // This must be done outside of the above section or a deadlock may occur.
  + if (!fMerkleRootCorrect)
  + {
  + LOCK(cs_main);
  + Misbehaving(pfrom->GetId(), 100);
  + return error("xthinblock merkelroot does not match computed merkleroot, peer=%d", pfrom->GetId());
  + }
  +
  // There is a remote possiblity of a Tx hash collision therefore if it occurs we re-request a normal
  // thinblock which has the full Tx hash data rather than just the truncated hash.
  if (collision) {
  