Create setter to modify blocktime consensus params at run-time

This commit is contained in:
Duke Leto
2020-07-11 11:10:15 -04:00
parent 55890a0543
commit d516a21d54
3 changed files with 14 additions and 7 deletions

View File

@@ -85,6 +85,7 @@ int32_t komodo_block2pubkey33(uint8_t *pubkey33,CBlock *block);
//void komodo_broadcast(CBlock *pblock,int32_t limit);
bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey);
void komodo_setactivation(int32_t height);
void hush_changeblocktime();
void komodo_pricesupdate(int32_t height,CBlock *pblock);
BlockMap mapBlockIndex;
@@ -3233,9 +3234,8 @@ bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex
int nHeight = pindex->pprev->GetHeight();
if (ishush3 && (ASSETCHAINS_BLOCKTIME != 150) && (nHeight < nFirstHalvingHeight)) {
LogPrintf("%s: Setting blocktime to 150s at height %d!\n",__func__,nHeight);
ASSETCHAINS_BLOCKTIME = 150;
Params.GetConsensus().nMaxFutureBlockTime = 7 * ASSETCHAINS_BLOCKTIME;
Params.GetConsensus().nPowTargetSpacing = ASSETCHAINS_BLOCKTIME;
ASSETCHAINS_BLOCKTIME = 150;
hush_changeblocktime();
}
@@ -3388,8 +3388,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
if (ishush3 && (ASSETCHAINS_BLOCKTIME != 75) && (chainActive.Height() >= nFirstHalvingHeight)) {
LogPrintf("%s: Blocktime halving to 75s at height %d!\n",__func__,pindex->GetHeight());
ASSETCHAINS_BLOCKTIME = 75;
Params.GetConsensus().nMaxFutureBlockTime = 7 * ASSETCHAINS_BLOCKTIME;
Params.GetConsensus().nPowTargetSpacing = ASSETCHAINS_BLOCKTIME;
hush_changeblocktime();
}
bool fExpensiveChecks = true;
@@ -3992,8 +3991,7 @@ void static UpdateTip(CBlockIndex *pindexNew) {
if (ASSETCHAINS_BLOCKTIME != 75 && (chainActive.Height() >= nFirstHalvingHeight)) {
LogPrintf("%s: Blocktime halving to 75s at height %d!\n",__func__,chainActive.Height());
ASSETCHAINS_BLOCKTIME = 75;
Params.GetConsensus().nMaxFutureBlockTime = 7 * ASSETCHAINS_BLOCKTIME;
Params.GetConsensus().nPowTargetSpacing = ASSETCHAINS_BLOCKTIME;
hush_changeblocktime();
}
}