// minimum amount of work that could possibly be required nTime after
// minimum work required was nBase
//
-unsigned int ComputeMinWork(unsigned int nBase, int64 nTime, bool fProofOfStake, int nHeight)
+unsigned int ComputeMinWork(unsigned int nBase, int64 nTime)
{
CBigNum bnTargetLimit = bnProofOfWorkLimit;
- if(fProofOfStake)
- {
- // Proof-of-Stake blocks has own target limit since nVersion=3 supermajority on mainNet and always on testNet
- if(fTestNet || nHeight > 15000)
- bnTargetLimit = bnProofOfStakeLimit;
- else if(nHeight > 14060)
- bnTargetLimit = bnProofOfStakeHardLimit;
- }
-
CBigNum bnResult;
bnResult.SetCompact(nBase);
bnResult *= 2;
if(fProofOfStake)
{
// Proof-of-Stake blocks has own target limit since nVersion=3 supermajority on mainNet and always on testNet
- if(fTestNet || (pindexLast->nHeight + 1 > 15000))
- bnTargetLimit = bnProofOfStakeLimit;
- else if(pindexLast->nHeight + 1 > 14060)
+ if(fTestNet)
bnTargetLimit = bnProofOfStakeHardLimit;
+ else
+ {
+ if(pindexLast->nHeight + 1 > 15000)
+ bnTargetLimit = bnProofOfStakeLimit;
+ else if(pindexLast->nHeight + 1 > 14060)
+ bnTargetLimit = bnProofOfStakeHardLimit;
+ }
}
if (pindexLast == NULL)
return true;
}
-int CBlock::GetBlockHeight() const
-{
- if(nVersion == 1)
- return 0;
-
- if(vtx[0].vin[0].scriptSig[0] > 4)
- return vtx[0].vin[0].scriptSig[0] - 80;
-
- int nBlockHeight = 0;
-
- memcpy((void *)&nBlockHeight, (const void *)&vtx[0].vin[0].scriptSig[1], vtx[0].vin[0].scriptSig[0]);
-
-#ifdef BIGENDIAN
- return htonl(nBlockHeight);
-#else
- return nBlockHeight;
-#endif
-}
-
bool CBlock::AcceptBlock()
{
// Check for duplicate
return error("AcceptBlock() : rejected by synchronized checkpoint");
// Reject block.nVersion < 3 blocks since 95% threshold on mainNet and always on testNet:
- if (nVersion < 3 && ((!fTestNet && nHeight > 14060) || (fTestNet && nHeight > 0)))
+ if (nVersion < 3 && (nHeight > 14060))
return error("CheckBlock() : rejected nVersion < 3 block");
CScript expect = CScript() << nHeight;
if (!std::equal(expect.begin(), expect.end(), vtx[0].vin[0].scriptSig.begin()))
return DoS(100, error("AcceptBlock() : block height mismatch in coinbase"));
- /**
- * TODO: replace previous check with this.
- */
-
- // if(nHeight != GetBlockHeight())
- // return DoS(100, error("AcceptBlock() : block height mismatch in coinbase"));
-
-
// Write block to history file
if (!CheckDiskSpace(::GetSerializeSize(*this, SER_DISK, CLIENT_VERSION)))
return error("AcceptBlock() : out of disk space");
CBigNum bnNewBlock;
bnNewBlock.SetCompact(pblock->nBits);
CBigNum bnRequired;
- bnRequired.SetCompact(ComputeMinWork(GetLastBlockIndex(pcheckpoint, pblock->IsProofOfStake())->nBits, deltaTime, pblock->IsProofOfStake(), pblock->GetBlockHeight()));
+ bnRequired.SetCompact(ComputeMinWork(GetLastBlockIndex(pcheckpoint, pblock->IsProofOfStake())->nBits, deltaTime));
if (bnNewBlock > bnRequired)
{