diff --git a/src/chainparams.cpp b/src/chainparams.cpp index f14b1e1..5d447bb 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -238,6 +238,12 @@ class CTestNetParams : public CChainParams { fRequireStandard = false; fMineBlocksOnDemand = false; + // Hardfork params + consensus.nSwitchKGW2 = 0; + consensus.nSwitchKGW2prefork = 0; + consensus.nSwitchKGW2postfork = 0; + consensus.nSwitchDGW = 1; + checkpointData = (CCheckpointData) { { //{10000, uint256S("0x")}, @@ -308,6 +314,12 @@ class CRegTestParams : public CChainParams { fRequireStandard = false; fMineBlocksOnDemand = true; + // Hardfork params + consensus.nSwitchKGW2 = 0; + consensus.nSwitchKGW2prefork = 0; + consensus.nSwitchKGW2postfork = 0; + consensus.nSwitchDGW = 1; + checkpointData = (CCheckpointData) { { {0, uint256S("0x2574af5d531ba2c7b1b2994de62ae356699cb579cd744cf5dc8a565fce6db638")}, diff --git a/src/komodo_validation015.h b/src/komodo_validation015.h index 350df18..e46d8b3 100755 --- a/src/komodo_validation015.h +++ b/src/komodo_validation015.h @@ -55,6 +55,7 @@ #include //#include +#include #include #define SATOSHIDEN ((uint64_t)100000000L) @@ -1028,11 +1029,14 @@ void komodo_notarized_update(int32_t nHeight,int32_t notarized_height,uint256 no char fname[512];int32_t latestht = 0; //decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); pthread_mutex_init(&komodo_mutex,NULL); + std::string suffix = Params().NetworkIDString() == "main" ? "" : "_" + Params().NetworkIDString(); + std::string sep; #ifdef _WIN32 - sprintf(fname,"%s\\notarizations",GetDataDir().string().c_str()); + sep = "\\"; #else - sprintf(fname,"%s/notarizations",GetDataDir().string().c_str()); + sep = "/"; #endif + sprintf(fname,"%s%snotarizations%s",GetDefaultDataDir().string().c_str(), sep.c_str(), suffix.c_str()); printf("fname.(%s)\n",fname); if ( (fp= fopen(fname,"rb+")) == 0 ) fp = fopen(fname,"wb+"); diff --git a/src/pow.cpp b/src/pow.cpp index fb7eb5c..3030c51 100755 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -280,11 +280,27 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead int64_t PastSecondsMin = TimeDaySeconds * 0.01; int64_t PastSecondsMax = TimeDaySeconds * 0.14; - //unsigned int nProofOfWorkLimit = UintToArith256(params.powLimit).GetCompact(); + unsigned int nProofOfWorkLimit = UintToArith256(params.powLimit).GetCompact(); // Genesis block - //if (pindexLast == NULL) - // return nProofOfWorkLimit; + if (pindexLast == NULL) + return nProofOfWorkLimit; +if (params.fPowAllowMinDifficultyBlocks) + { + // Special difficulty rule for testnet: + // If the new block's timestamp is more than 2* 10 minutes + // then allow mining of a min-difficulty block. + if (pblock->GetBlockTime() > pindexLast->GetBlockTime() + params.nPowTargetSpacing*2) + return nProofOfWorkLimit; + else + { + // Return the last non-special-min-difficulty-rules-block + const CBlockIndex* pindex = pindexLast; + while (pindex->pprev && pindex->nHeight % params.DifficultyAdjustmentInterval() != 0 && pindex->nBits == nProofOfWorkLimit) + pindex = pindex->pprev; + return pindex->nBits; + } +} if(pindexLast->nHeight+1 < params.nSwitchKGW2) { @@ -365,4 +381,4 @@ bool CheckProofOfWork(uint256 hash, unsigned int nBits, const Consensus::Params& return false; return true; -} \ No newline at end of file +}