message: Add check for duplicate orphan block and stake
diff: @@ -3286,6 +3286,17 @@ bool ProcessNetBlock(const CChainParams& chainparams, const std::shared_ptr<cons
  {
  LOCK(cs_main);
  + // Check for duplicate orphan block
  + uint256 hash = pblock->GetHash();
  + if (mapOrphanBlocks.count(hash))
  + return error("ProcessNetBlock() : already have block (orphan) %s", hash.ToString());
  +
  + // ppcoin: check proof-of-stake
  + // Limited duplicity on stake: prevents block flood attack
  + // Duplicate stake allowed only when there is orphan child block
  + if (!fReindex && !fImporting && pblock->IsProofOfStake() && (setStakeSeen.count(pblock->GetProofOfStake()) > 1) && !mapOrphanBlocksByPrev.count(hash))
  + return error("ProcessNetBlock() : duplicate proof-of-stake (%s, %d) for block %s", pblock->GetProofOfStake().first.ToString(), pblock->GetProofOfStake().second, hash.ToString());
  +
  // Check for the checkpoint
  if (chainActive.Tip() && pblock->hashPrevBlock != chainActive.Tip()->GetBlockHash())
  {
  