Primecoin: Block hash switches to serialized hash
Block header hash must be at least 2**255master
parent
f7d1524078
commit
1d7c3a6d35
|
@ -38,6 +38,12 @@ int main(int argc, char *argv[])
|
|||
|
||||
while (true)
|
||||
{
|
||||
if (block.GetHeaderHash() < hashBlockHeaderLimit)
|
||||
{
|
||||
block.nNonce++;
|
||||
fNewBlock = true;
|
||||
continue;
|
||||
}
|
||||
unsigned int p = 7;
|
||||
CBigNum bnPrimorial;
|
||||
Primorial(p, bnPrimorial);
|
||||
|
|
16
src/main.cpp
16
src/main.cpp
|
@ -2770,17 +2770,17 @@ bool InitBlockIndex() {
|
|||
block.vtx.push_back(txNew);
|
||||
block.hashPrevBlock = 0;
|
||||
block.hashMerkleRoot = block.BuildMerkleTree();
|
||||
block.nTime = 1372887417;
|
||||
block.nTime = 1372909928;
|
||||
block.nBits = TargetFromInt(4u);
|
||||
block.nNonce = 0;
|
||||
block.nNonce = 2;
|
||||
|
||||
if (fTestNet)
|
||||
{
|
||||
block.nTime = 1372887417;
|
||||
block.nNonce = 0;
|
||||
block.nTime = 1372909928;
|
||||
block.nNonce = 2;
|
||||
}
|
||||
|
||||
block.bnPrimeChainMultiplier = 2 * 3 * 5 * 7 * 77755;
|
||||
block.bnPrimeChainMultiplier = 2 * 3 * 5 * 7 * 887334;
|
||||
|
||||
//// debug print
|
||||
uint256 hash = block.GetHash();
|
||||
|
@ -4620,11 +4620,9 @@ void static BitcoinMiner(CWallet *pwallet)
|
|||
// Primecoin: try to find hash divisible by primorial
|
||||
CBigNum bnHashFactor;
|
||||
Primorial(nPrimorialHashFactor, bnHashFactor);
|
||||
while (CBigNum(pblock->GetHeaderHash()) % bnHashFactor != 0 && pblock->nNonce < 0xffff0000)
|
||||
while ((pblock->GetHeaderHash() < hashBlockHeaderLimit || CBigNum(pblock->GetHeaderHash()) % bnHashFactor != 0) && pblock->nNonce < 0xffff0000)
|
||||
pblock->nNonce++;
|
||||
if (CBigNum(pblock->GetHeaderHash()) % bnHashFactor != 0)
|
||||
continue;
|
||||
if (pblock->GetHeaderHash() == 0)
|
||||
if (pblock->nNonce >= 0xffff0000)
|
||||
continue;
|
||||
// Primecoin: primorial fixed multiplier
|
||||
CBigNum bnPrimorial;
|
||||
|
|
|
@ -64,8 +64,8 @@ static const int fHaveUPnP = true;
|
|||
static const int fHaveUPnP = false;
|
||||
#endif
|
||||
|
||||
static const uint256 hashGenesisBlockOfficial("0x69b988d741c862e027a61f93e38c3a6d071fd361d3a8a9c3999d1234f986c568");
|
||||
static const uint256 hashGenesisBlockTestNet("0x69b988d741c862e027a61f93e38c3a6d071fd361d3a8a9c3999d1234f986c568");
|
||||
static const uint256 hashGenesisBlockOfficial("0x3b1c7074fcc727484fdf84a1296a124615e556f4d972ce06ebd1590098c21cec");
|
||||
static const uint256 hashGenesisBlockTestNet("0x3b1c7074fcc727484fdf84a1296a124615e556f4d972ce06ebd1590098c21cec");
|
||||
|
||||
extern CScript COINBASE_FLAGS;
|
||||
|
||||
|
@ -1325,7 +1325,7 @@ public:
|
|||
uint256 GetHash() const
|
||||
{
|
||||
CDataStream ss(SER_GETHASH, 0);
|
||||
ss << GetHeaderHash() << bnPrimeChainMultiplier;
|
||||
ss << nVersion << hashPrevBlock << hashMerkleRoot << nTime << nBits << nNonce << bnPrimeChainMultiplier;
|
||||
return Hash(ss.begin(), ss.end());
|
||||
}
|
||||
|
||||
|
|
|
@ -442,12 +442,15 @@ bool CheckPrimeProofOfWork(uint256 hashBlockHeader, unsigned int nBits, const CB
|
|||
if (TargetGetLength(nBits) < nTargetMinLength || TargetGetLength(nBits) > 99)
|
||||
return error("CheckPrimeProofOfWork() : invalid chain length target %s", TargetToString(nBits).c_str());
|
||||
|
||||
// Check header hash limit
|
||||
if (hashBlockHeader < hashBlockHeaderLimit)
|
||||
return error("CheckPrimeProofOfWork() : block header hash under limit");
|
||||
// Check target for prime proof-of-work
|
||||
CBigNum bnPrimeChainOrigin = CBigNum(hashBlockHeader) * bnPrimeChainMultiplier;
|
||||
if (bnPrimeChainOrigin <= bnPrimeMin)
|
||||
if (bnPrimeChainOrigin < bnPrimeMin)
|
||||
return error("CheckPrimeProofOfWork() : prime too small");
|
||||
// First prime in chain must not exceed cap
|
||||
if (bnPrimeChainOrigin >= bnPrimeMax)
|
||||
if (bnPrimeChainOrigin > bnPrimeMax)
|
||||
return error("CheckPrimeProofOfWork() : prime too big");
|
||||
|
||||
// Check prime chain
|
||||
|
|
|
@ -7,10 +7,12 @@
|
|||
|
||||
#include "main.h"
|
||||
|
||||
static const unsigned int nMaxSieveSize = 1000000u;
|
||||
static const uint256 hashBlockHeaderLimit = (uint256(1) << 255);
|
||||
static const CBigNum bnOne = 1;
|
||||
static const CBigNum bnPrimeMax = (bnOne << 2000) - 1;
|
||||
static const CBigNum bnPrimeMin = (bnOne << 256);
|
||||
static const unsigned int nMaxSieveSize = 1000000u;
|
||||
static const CBigNum bnPrimeMin = (bnOne << 255);
|
||||
|
||||
|
||||
// Generate small prime table
|
||||
void GeneratePrimeTable();
|
||||
|
|
Loading…
Reference in New Issue