From 54fd5f323411d63324c8549af137763a6bb9836c Mon Sep 17 00:00:00 2001 From: Evan Date: Tue, 8 Apr 2014 02:09:55 -0700 Subject: [PATCH] fix for DGW till perm fix later --- src/main.cpp | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 1830ac3e07..118bf60e85 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2369,19 +2369,37 @@ bool CBlock::AcceptBlock(CValidationState &state, CDiskBlockPos *dbp) pindexPrev = (*mi).second; nHeight = pindexPrev->nHeight+1; + #ifdef _WIN32 + // Check proof of work + if(nHeight >= 34140){ + unsigned int nBitsNext = GetNextWorkRequired(pindexPrev, this); + double n1 = ConvertBitsToDouble(nBits); + double n2 = ConvertBitsToDouble(nBitsNext); - // Check proof of work - if(nHeight >= 34140 && nHeight <= 45000){ - unsigned int nBitsNext = GetNextWorkRequired(pindexPrev, this); - double n1 = ConvertBitsToDouble(nBits); - double n2 = ConvertBitsToDouble(nBitsNext); - if (abs(n1-n2) > n1*0.2) - return state.DoS(100, error("AcceptBlock() : incorrect proof of work (DGW pre-fork)")); - } else { - if (nBits != GetNextWorkRequired(pindexPrev, this)) - return state.DoS(100, error("AcceptBlock() : incorrect proof of work")); - } - + if (nHeight <= 45000) { + if (abs(n1-n2) > n1*0.2) + return state.DoS(100, error("AcceptBlock() : incorrect proof of work (DGW pre-fork)")); + } else { + if (abs(n1-n2) > n1*0.005) + return state.DoS(100, error("AcceptBlock() : incorrect proof of work (DGW2)")); + } + } else { + if (nBits != GetNextWorkRequired(pindexPrev, this)) + return state.DoS(100, error("AcceptBlock() : incorrect proof of work")); + } + #else + // Check proof of work + if(nHeight >= 34140 && nHeight <= 45000){ + unsigned int nBitsNext = GetNextWorkRequired(pindexPrev, this); + double n1 = ConvertBitsToDouble(nBits); + double n2 = ConvertBitsToDouble(nBitsNext); + if (abs(n1-n2) > n1*0.2) + return state.DoS(100, error("AcceptBlock() : incorrect proof of work (DGW pre-fork)")); + } else { + if (nBits != GetNextWorkRequired(pindexPrev, this)) + return state.DoS(100, error("AcceptBlock() : incorrect proof of work")); + } + #endif // Prevent blocks from too far in the future if(fTestNet || nHeight >= 45000){