Skip to content

Commit

Permalink
Merge pull request #28 from samadsajanlal/master
Browse files Browse the repository at this point in the history
fix testnet, clean up minor komodo notary logic
  • Loading branch information
samadsajanlal authored Jan 10, 2019
2 parents 6e072e1 + 9089d88 commit ec765b3
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 6 deletions.
12 changes: 12 additions & 0 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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")},
Expand Down Expand Up @@ -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")},
Expand Down
8 changes: 6 additions & 2 deletions src/komodo_validation015.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@

#include <wallet/wallet.h>
//#include <key_io.h>
#include <chainparams.h>
#include <base58.h>

#define SATOSHIDEN ((uint64_t)100000000L)
Expand Down Expand Up @@ -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+");
Expand Down
24 changes: 20 additions & 4 deletions src/pow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -365,4 +381,4 @@ bool CheckProofOfWork(uint256 hash, unsigned int nBits, const Consensus::Params&
return false;

return true;
}
}

0 comments on commit ec765b3

Please sign in to comment.