Skip to content

Commit

Permalink
Merge pull request #2 from sunnyking/master
Browse files Browse the repository at this point in the history
Protocol switch of entropy bit for Novacoin support of p2pool
CryptoManiac committed Mar 26, 2013
2 parents cccbfb2 + 002d24c commit 0891c01
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
@@ -1784,7 +1784,7 @@ bool CBlock::AddToBlockIndex(unsigned int nFile, unsigned int nBlockPos)
pindexNew->bnChainTrust = (pindexNew->pprev ? pindexNew->pprev->bnChainTrust : 0) + pindexNew->GetBlockTrust();

// ppcoin: compute stake entropy bit for stake modifier
if (!pindexNew->SetStakeEntropyBit(GetStakeEntropyBit()))
if (!pindexNew->SetStakeEntropyBit(GetStakeEntropyBit(pindexNew->nHeight)))
return error("AddToBlockIndex() : SetStakeEntropyBit() failed");

// ppcoin: record proof-of-stake hash value
12 changes: 11 additions & 1 deletion src/main.h
Original file line number Diff line number Diff line change
@@ -966,8 +966,18 @@ class CBlock
void UpdateTime(const CBlockIndex* pindexPrev);

// ppcoin: entropy bit for stake modifier if chosen by modifier
unsigned int GetStakeEntropyBit() const
unsigned int GetStakeEntropyBit(unsigned int nHeight) const
{
// Protocol switch to support p2pool at novacoin block #9689
if (nHeight >= 9689)
{
// Take last bit of block hash as entropy bit
unsigned int nEntropyBit = ((GetHash().Get64()) & 1llu);
if (fDebug && GetBoolArg("-printstakemodifier"))
printf("GetStakeEntropyBit: nHeight=%u hashBlock=%s nEntropyBit=%u\n", nHeight, GetHash().ToString().c_str(), nEntropyBit);
return nEntropyBit;
}
// Before novacoin block #9689 - old protocol
uint160 hashSig = Hash160(vchBlockSig);
if (fDebug && GetBoolArg("-printstakemodifier"))
printf("GetStakeEntropyBit: hashSig=%s", hashSig.ToString().c_str());

0 comments on commit 0891c01

Please sign in to comment.