X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Fmain.cpp;h=1b435d57c10b9fcf928d0bcd9d326a550437950a;hb=193076d3a965c11ab7c811f249ceaa9e54714920;hp=0e22b110fee353594811fc4f0196be78396d02ca;hpb=69599ecf22ab6ed50801c6641dd17cd4c24e3e39;p=novacoin.git diff --git a/src/main.cpp b/src/main.cpp index 0e22b11..1b435d5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2180,7 +2180,7 @@ bool CBlock::AddToBlockIndex(unsigned int nFile, unsigned int nBlockPos) pindexNew->nChainTrust = (pindexNew->pprev ? pindexNew->pprev->nChainTrust : 0) + pindexNew->GetBlockTrust(); // ppcoin: compute stake entropy bit for stake modifier - if (!pindexNew->SetStakeEntropyBit(GetStakeEntropyBit(pindexNew->nTime))) + if (!pindexNew->SetStakeEntropyBit(GetStakeEntropyBit(pindexNew->nHeight))) return error("AddToBlockIndex() : SetStakeEntropyBit() failed"); // ppcoin: record proof-of-stake hash value @@ -2291,26 +2291,9 @@ bool CBlock::CheckBlock(bool fCheckPOW, bool fCheckMerkleRoot, bool fCheckSig) c return DoS(50, error("CheckBlock() : coinstake timestamp violation nTimeBlock=%" PRId64 " nTimeTx=%u", GetBlockTime(), vtx[1].nTime)); // NovaCoin: check proof-of-stake block signature - if (fCheckSig && !CheckBlockSignature(true)) + if (fCheckSig && !CheckBlockSignature()) return DoS(100, error("CheckBlock() : bad proof-of-stake block signature")); } - else - { - // Should we check proof-of-work block signature or not? - // - // * Always skip on TestNet - // * Perform checking for the first 9689 blocks - // * Perform checking since last checkpoint until 20 Sep 2013 (will be removed after) - - if(!fTestNet && fCheckSig) - { - bool checkEntropySig = (GetBlockTime() < ENTROPY_SWITCH_TIME); - - // NovaCoin: check proof-of-work block signature - if (checkEntropySig && !CheckBlockSignature(false)) - return DoS(100, error("CheckBlock() : bad proof-of-work block signature")); - } - } // Check transactions BOOST_FOREACH(const CTransaction& tx, vtx) @@ -2685,55 +2668,27 @@ bool CBlock::SignBlock(CWallet& wallet) } // ppcoin: check block signature -bool CBlock::CheckBlockSignature(bool fProofOfStake) const +bool CBlock::CheckBlockSignature() const { - if (GetHash() == (!fTestNet ? hashGenesisBlock : hashGenesisBlockTestNet)) - return vchBlockSig.empty(); + if (IsProofOfWork()) + return true; vector vSolutions; txnouttype whichType; - if(fProofOfStake) - { - const CTxOut& txout = vtx[1].vout[1]; + const CTxOut& txout = vtx[1].vout[1]; - if (!Solver(txout.scriptPubKey, whichType, vSolutions)) - return false; - if (whichType == TX_PUBKEY) - { - valtype& vchPubKey = vSolutions[0]; - CKey key; - if (!key.SetPubKey(vchPubKey)) - return false; - if (vchBlockSig.empty()) - return false; - return key.Verify(GetHash(), vchBlockSig); - } - } - else + if (!Solver(txout.scriptPubKey, whichType, vSolutions)) + return false; + if (whichType == TX_PUBKEY) { - for(unsigned int i = 0; i < vtx[0].vout.size(); i++) - { - const CTxOut& txout = vtx[0].vout[i]; - - if (!Solver(txout.scriptPubKey, whichType, vSolutions)) - return false; - - if (whichType == TX_PUBKEY) - { - // Verify - valtype& vchPubKey = vSolutions[0]; - CKey key; - if (!key.SetPubKey(vchPubKey)) - continue; - if (vchBlockSig.empty()) - continue; - if(!key.Verify(GetHash(), vchBlockSig)) - continue; - - return true; - } - } + valtype& vchPubKey = vSolutions[0]; + CKey key; + if (!key.SetPubKey(vchPubKey)) + return false; + if (vchBlockSig.empty()) + return false; + return key.Verify(GetHash(), vchBlockSig); } return false; }