From 002d24c658e4a2d8306cf69c62ac3c666d106f64 Mon Sep 17 00:00:00 2001 From: Sunny King Date: Tue, 26 Mar 2013 05:27:29 +0000 Subject: [PATCH] Protocol switch of entropy bit calculation for novacoin support of p2pool Note: Upgrade required before March 30 --- src/main.cpp | 2 +- src/main.h | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index d92f528..3c8a4a6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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 diff --git a/src/main.h b/src/main.h index 7e05562..e3f454f 100644 --- a/src/main.h +++ b/src/main.h @@ -966,8 +966,18 @@ public: 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()); -- 1.7.1