Skip to content

Commit

Permalink
Bug/difficulty fix (#141)
Browse files Browse the repository at this point in the history
* Modified logs for merchantnodes

* Bumped version. Added difficulty adjustment max step
  • Loading branch information
durkmurder authored May 28, 2019
1 parent b8311b1 commit 3dbea94
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N)
AC_PREREQ([2.60])
define(_CLIENT_VERSION_MAJOR, 1)
define(_CLIENT_VERSION_MINOR, 0)
define(_CLIENT_VERSION_REVISION, 19)
define(_CLIENT_VERSION_REVISION, 20)
define(_CLIENT_VERSION_BUILD, 0)
define(_CLIENT_VERSION_IS_RELEASE, true)
define(_COPYRIGHT_YEAR, 2018)
Expand Down
3 changes: 3 additions & 0 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ class CMainParams : public CChainParams {
consensus.nTPoSContractSignatureDeploymentTime = 1523127600;
consensus.nPowKGWHeight = 15200;
consensus.nPowDGWHeight = 24;
consensus.nMaxBlockSpacingFixDeploymentHeight = 674980; // apprx 28 of June
consensus.fPowAllowMinDifficultyBlocks = false;
consensus.fPowNoRetargeting = false;
consensus.nRuleChangeActivationThreshold = 1080; // 75% of 2016
Expand Down Expand Up @@ -235,6 +236,7 @@ class CTestNetParams : public CChainParams {
consensus.fPowNoRetargeting = false;
consensus.nPowKGWHeight = 4001; // nPowKGWHeight >= nPowDGWHeight means "no KGW"
consensus.nPowDGWHeight = 4001;
consensus.nMaxBlockSpacingFixDeploymentHeight = 0;
consensus.nStakeMinAge = 60 * 60;
consensus.nStakeMaxAge = 60 * 60 * 24; // one day
consensus.nCoinbaseMaturity = 20;
Expand Down Expand Up @@ -362,6 +364,7 @@ class CRegTestParams : public CChainParams {
consensus.nPowKGWHeight = 4001; // nPowKGWHeight >= nPowDGWHeight means "no KGW"
consensus.nPowDGWHeight = 4001;
consensus.nLastPoWBlock = 75;
consensus.nMaxBlockSpacingFixDeploymentHeight = 0;
consensus.nStakeMinAge = 60 * 60;
consensus.nStakeMaxAge = 60 * 60 * 24; // one day
consensus.nCoinbaseMaturity = 20;
Expand Down
1 change: 1 addition & 0 deletions src/consensus/params.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ struct Params {
int nStakeMaxAge;
int nCoinbaseMaturity;
int nTPoSContractSignatureDeploymentTime;
int nMaxBlockSpacingFixDeploymentHeight;
};
} // namespace Consensus

Expand Down
5 changes: 5 additions & 0 deletions src/pow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ unsigned int static PoSWorkRequired(const CBlockIndex* pindexLast, const Consens
if (nActualSpacing < 0)
nActualSpacing = 1;

if(pindexLast->nHeight > params.nMaxBlockSpacingFixDeploymentHeight)
{
nActualSpacing = std::min(nActualSpacing, nTargetSpacing * 10);
}

// ppcoin: target change every block
// ppcoin: retarget with exponential moving toward target spacing
arith_uint256 bnNew;
Expand Down
9 changes: 7 additions & 2 deletions src/tpos/merchantnodeman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <utilstrencodings.h>
#include <util.h>
#include <init.h>
#include <key_io.h>
#include <netmessagemaker.h>

/** Merchantnode manager */
Expand Down Expand Up @@ -354,7 +355,7 @@ void CMerchantnodeMan::DsegUpdate(CNode* pnode, CConnman& connman)
int64_t askAgain = GetTime() + DSEG_UPDATE_SECONDS;
mWeAskedForMerchantnodeList[pnode->addr] = askAgain;

LogPrint(BCLog::MERCHANTNODE, "CMerchantnodeMan::DsegUpdate -- asked %s for the list\n", pnode->addr.ToString());
LogPrintf("CMerchantnodeMan::DsegUpdate -- asked %s for the list\n", pnode->addr.ToString());
}

CMerchantnode* CMerchantnodeMan::Find(const CPubKey &pubKeyMerchantnode)
Expand Down Expand Up @@ -732,7 +733,11 @@ void CMerchantnodeMan::AskForMissing(CConnman &connman)

for(auto &&it : mUnknownMerchantnodes)
{
shouldAsk |= (it.second >= 10);
if(it.second >= 10)
{
shouldAsk = true;
LogPrintf("Asking for merchantnode with address: %s\n", EncodeDestination(it.first));
}
}

if(shouldAsk)
Expand Down

0 comments on commit 3dbea94

Please sign in to comment.