Browse Source

This Shit Seems To Work

dev
Duke Leto 4 years ago
parent
commit
310ed2a434
  1. 34
      src/main.cpp
  2. 2
      src/pow.cpp

34
src/main.cpp

@ -5234,16 +5234,32 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta
int nHeight = pindexPrev->GetHeight()+1;
bool ishush3 = strncmp(SMART_CHAIN_SYMBOL, "HUSH3",5) == 0 ? true : false;
// Check Proof-of-Work
if ( (SMART_CHAIN_SYMBOL[0] != 0 || nHeight < 235300 || nHeight > 236000) && block.nBits != GetNextWorkRequired(pindexPrev, &block, consensusParams)) {
cout << "Incorrect Proof-of-Work! " <<
block.nBits << " block.nBits vs. calc " <<
GetNextWorkRequired(pindexPrev, &block, consensusParams) <<
" for height " << nHeight << " " <<
block.GetHash().ToString() << " with time " <<
block.GetBlockTime() << endl;
if(ishush3) {
unsigned int nNextWork = GetNextWorkRequired(pindexPrev, &block, consensusParams);
unsigned int diffbits = nNextWork > block.nBits ? nNextWork-block.nBits : block.nBits-nNextWork;
// The change of blocktime from 150s to 75s seems to have messed up our difficulty calc
if ((nHeight < 340000 || nHeight > 342500) && block.nBits != nNextWork) {
cout << "Incorrect HUSH Proof-of-Work at height " << nHeight << " " << block.nBits << " block.nBits vs. calc " <<
nNextWork << " " << block.GetHash().ToString() << " @ " << block.GetBlockTime() << endl;
return state.DoS(100, error("%s: Incorrect Proof-of-Work at height %d diffbits=%u", __func__, nHeight, diffbits), REJECT_INVALID, "bad-diffbits");
} else {
fprintf(stderr,"%s: Ignoring weird nBits %u with diffbits %u for height %d\n", __func__, block.nBits, diffbits, nHeight);
}
} else {
// TODO: unify this with the code above
if ( block.nBits != GetNextWorkRequired(pindexPrev, &block, consensusParams)) {
cout << "Incorrect Proof-of-Work! " << block.nBits << " block.nBits vs. calc " <<
GetNextWorkRequired(pindexPrev, &block, consensusParams) <<
" for height " << nHeight << " " <<
block.GetHash().ToString() << " with time " <<
block.GetBlockTime() << endl;
return state.DoS(100, error("%s: Incorrect Proof-of-Work at height %d", __func__, nHeight), REJECT_INVALID, "bad-diffbits");
return state.DoS(100, error("%s: Incorrect Proof-of-Work at height %d", __func__, nHeight), REJECT_INVALID, "bad-diffbits");
}
}
// Check timestamp against prev
@ -5409,7 +5425,7 @@ bool AcceptBlockHeader(int32_t *futureblockp,const CBlockHeader& block, CValidat
return false;
}
if(fDebug) {
fprintf(stderr,"%s: ContextualCheckBlockHeader passed\n", hash.ToString());
fprintf(stderr,"%s: ContextualCheckBlockHeader passed: %s\n", __func__, hash.ToString().c_str());
}
if (pindex == NULL)
{

2
src/pow.cpp

@ -544,7 +544,7 @@ unsigned int CalculateNextWorkRequired(arith_uint256 bnAvg,
LogPrint("pow", "After: %08x %s\n", bnNew.GetCompact(), bnNew.ToString());
if(fDebug)
fprintf(stderr,"%s: nbits=%u\n",__func__,nbits);
fprintf(stderr,"%s: nbits=%u\n",__func__,bnNew.GetCompact());
return bnNew.GetCompact();
}

Loading…
Cancel
Save