Fix DGW v1 and v2 architecture issues.
This commit is contained in:
parent
5a77c79d24
commit
f8105535fe
16
TODO.md
16
TODO.md
@ -1,7 +1,7 @@
|
||||
Porting Bitcoin 0.9.3 to Darkcoin
|
||||
=================================
|
||||
|
||||
Staging tree for Darkcoin-0.9.3.
|
||||
Staging tree for Darkcoin-0.11.0.
|
||||
|
||||
|
||||
DONE:
|
||||
@ -17,19 +17,19 @@ DONE:
|
||||
- Adjusted algorithm (X11)
|
||||
- Updated subsidity function (Block value)
|
||||
- Adjusted wallet keypool size to 1000 and added loading indicator on fresh wallet load
|
||||
- Adjusted difficulty and blockvalue (KGW, DGW based on blockheight)
|
||||
|
||||
|
||||
MUST-HAVE:
|
||||
MANDATORY:
|
||||
----------
|
||||
|
||||
- Adjust difficulty (KGW, DGW based on blockheight)
|
||||
- Add masternode payment checks a.k.a. enforcement (based on blockheight)
|
||||
|
||||
|
||||
OPTIONAL:
|
||||
---------
|
||||
|
||||
- Remove Bitcoin dead weight (SHA256, hardcoded keys, nodes)
|
||||
|
||||
|
||||
ADD-ON:
|
||||
-------
|
||||
|
||||
- All the above for Testnet (including complete testnet reset)
|
||||
- Update strings and wallet layout/branding
|
||||
- Include Evan's public key for msg signing
|
||||
|
28
src/main.cpp
28
src/main.cpp
@ -2081,10 +2081,10 @@ bool ConnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex, C
|
||||
if (fBenchmark)
|
||||
LogPrintf("- Connect %u transactions: %.2fms (%.3fms/tx, %.3fms/txin)\n", (unsigned)block.vtx.size(), 0.001 * nTime, 0.001 * nTime / block.vtx.size(), nInputs <= 1 ? 0 : 0.001 * nTime / (nInputs-1));
|
||||
|
||||
if (block.vtx[0].GetValueOut() > GetBlockValue(pindex->nBits, pindex->nHeight, nFees))
|
||||
if (block.vtx[0].GetValueOut() > GetBlockValue(pindex->pprev->nBits, pindex->pprev->nHeight, nFees))
|
||||
return state.DoS(100,
|
||||
error("ConnectBlock() : coinbase pays too much (actual=%d vs limit=%d)",
|
||||
block.vtx[0].GetValueOut(), GetBlockValue(pindex->nBits, pindex->nHeight, nFees)),
|
||||
block.vtx[0].GetValueOut(), GetBlockValue(pindex->pprev->nBits, pindex->pprev->nHeight, nFees)),
|
||||
REJECT_INVALID, "bad-cb-amount");
|
||||
|
||||
if (!control.Wait())
|
||||
@ -2619,10 +2619,26 @@ bool AcceptBlock(CBlock& block, CValidationState& state, CDiskBlockPos* dbp)
|
||||
pindexPrev = (*mi).second;
|
||||
nHeight = pindexPrev->nHeight+1;
|
||||
|
||||
// Check proof of work
|
||||
if (block.nBits != GetNextWorkRequired(pindexPrev, &block))
|
||||
return state.DoS(100, error("AcceptBlock() : incorrect proof of work"),
|
||||
REJECT_INVALID, "bad-diffbits");
|
||||
if(TestNet()) {
|
||||
if (block.nBits != GetNextWorkRequired(pindexPrev, &block))
|
||||
return state.DoS(100, error("AcceptBlock() : incorrect proof of work"),
|
||||
REJECT_INVALID, "bad-diffbits");
|
||||
} else {
|
||||
// Check proof of work (Here for the architecture issues with DGW v1 and v2)
|
||||
if(nHeight <= 68589){
|
||||
unsigned int nBitsNext = GetNextWorkRequired(pindexPrev, &block);
|
||||
double n1 = ConvertBitsToDouble(block.nBits);
|
||||
double n2 = ConvertBitsToDouble(nBitsNext);
|
||||
|
||||
if (abs(n1-n2) > n1*0.5)
|
||||
return state.DoS(100, error("AcceptBlock() : incorrect proof of work (DGW pre-fork) - %f", abs(n1-n2)),
|
||||
REJECT_INVALID, "bad-diffbits");
|
||||
} else {
|
||||
if (block.nBits != GetNextWorkRequired(pindexPrev, &block))
|
||||
return state.DoS(100, error("AcceptBlock() : incorrect proof of work"),
|
||||
REJECT_INVALID, "bad-diffbits");
|
||||
}
|
||||
}
|
||||
|
||||
// Check timestamp against prev
|
||||
if (block.GetBlockTime() <= pindexPrev->GetMedianTimePast())
|
||||
|
Loading…
Reference in New Issue
Block a user