Create setter to modify blocktime consensus params at run-time
This commit is contained in:
@@ -544,6 +544,14 @@ int32_t MAX_BLOCK_SIZE(int32_t height)
|
||||
else return(2000000);
|
||||
}
|
||||
|
||||
// Change the Hush blocktime at run-time(!)
|
||||
void hush_changeblocktime()
|
||||
{
|
||||
pCurrentParams->consensus.nMaxFutureBlockTime = 7 * ASSETCHAINS_BLOCKTIME;
|
||||
pCurrentParams->consensus.nPowTargetSpacing = ASSETCHAINS_BLOCKTIME;
|
||||
fprintf(stderr,"HUSH blocktime changing to %d seconds\n",ASSETCHAINS_BLOCKTIME);
|
||||
}
|
||||
|
||||
void komodo_setactivation(int32_t height)
|
||||
{
|
||||
pCurrentParams->consensus.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight = height;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||
// Copyright (c) 2019-2020 The Hush developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
12
src/main.cpp
12
src/main.cpp
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user