X-Git-Url: https://git.novaco.in/?p=novacoin.git;a=blobdiff_plain;f=src%2Fmain.cpp;h=e229063ac64503c70aac01fc8c31a6ad124f277c;hp=4581fcf1696b2187e5f9bc516ed9be9044a54bf1;hb=a350e812fc913378759c61bd06cde1b749a3fb0d;hpb=496060e1442eb7765668c4ddc9b9aa9f8a2be5ed diff --git a/src/main.cpp b/src/main.cpp index 4581fcf..e229063 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1540,7 +1540,16 @@ bool CBlock::AcceptBlock() CBlockIndex* pindexPrev = (*mi).second; int nHeight = pindexPrev->nHeight+1; - // Check proof of work + // ppcoin: check for coinstake duplicate + if (IsProofOfStake()) + { // check if coinstake is already connected; that would imply the owner + // of the coinstake sent multiple blocks with the same coinstake + CTxIndex txindex; + if (CTxDB("r").ReadTxIndex(vtx[1].GetHash(), txindex)) + return error("AcceptBlock() : block %s has duplicate coinstake %s", hash.ToString().c_str(), vtx[1].GetHash().ToString().c_str()); + } + + // Check proof-of-work or proof-of-stake if (nBits != GetNextTargetRequired(pindexPrev, IsProofOfStake())) return DoS(100, error("AcceptBlock() : incorrect proof-of-work/proof-of-stake")); @@ -1608,7 +1617,7 @@ bool ProcessBlock(CNode* pfrom, CBlock* pblock) bnNewBlock.SetCompact(pblock->nBits); CBigNum bnRequired; bnRequired.SetCompact(ComputeMinWork(pcheckpoint->nBits, deltaTime)); - if (bnNewBlock > bnRequired) + if (pblock->IsProofOfWork() && bnNewBlock > bnRequired) { pfrom->Misbehaving(100); return error("ProcessBlock() : block with too little proof-of-work");