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);
|
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)
|
void komodo_setactivation(int32_t height)
|
||||||
{
|
{
|
||||||
pCurrentParams->consensus.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight = height;
|
pCurrentParams->consensus.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight = height;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||||
|
// Copyright (c) 2019-2020 The Hush developers
|
||||||
// Distributed under the MIT software license, see the accompanying
|
// Distributed under the MIT software license, see the accompanying
|
||||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
// 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);
|
//void komodo_broadcast(CBlock *pblock,int32_t limit);
|
||||||
bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey);
|
bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey);
|
||||||
void komodo_setactivation(int32_t height);
|
void komodo_setactivation(int32_t height);
|
||||||
|
void hush_changeblocktime();
|
||||||
void komodo_pricesupdate(int32_t height,CBlock *pblock);
|
void komodo_pricesupdate(int32_t height,CBlock *pblock);
|
||||||
|
|
||||||
BlockMap mapBlockIndex;
|
BlockMap mapBlockIndex;
|
||||||
@@ -3233,9 +3234,8 @@ bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex
|
|||||||
int nHeight = pindex->pprev->GetHeight();
|
int nHeight = pindex->pprev->GetHeight();
|
||||||
if (ishush3 && (ASSETCHAINS_BLOCKTIME != 150) && (nHeight < nFirstHalvingHeight)) {
|
if (ishush3 && (ASSETCHAINS_BLOCKTIME != 150) && (nHeight < nFirstHalvingHeight)) {
|
||||||
LogPrintf("%s: Setting blocktime to 150s at height %d!\n",__func__,nHeight);
|
LogPrintf("%s: Setting blocktime to 150s at height %d!\n",__func__,nHeight);
|
||||||
ASSETCHAINS_BLOCKTIME = 150;
|
ASSETCHAINS_BLOCKTIME = 150;
|
||||||
Params.GetConsensus().nMaxFutureBlockTime = 7 * ASSETCHAINS_BLOCKTIME;
|
hush_changeblocktime();
|
||||||
Params.GetConsensus().nPowTargetSpacing = ASSETCHAINS_BLOCKTIME;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -3388,8 +3388,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
|||||||
if (ishush3 && (ASSETCHAINS_BLOCKTIME != 75) && (chainActive.Height() >= nFirstHalvingHeight)) {
|
if (ishush3 && (ASSETCHAINS_BLOCKTIME != 75) && (chainActive.Height() >= nFirstHalvingHeight)) {
|
||||||
LogPrintf("%s: Blocktime halving to 75s at height %d!\n",__func__,pindex->GetHeight());
|
LogPrintf("%s: Blocktime halving to 75s at height %d!\n",__func__,pindex->GetHeight());
|
||||||
ASSETCHAINS_BLOCKTIME = 75;
|
ASSETCHAINS_BLOCKTIME = 75;
|
||||||
Params.GetConsensus().nMaxFutureBlockTime = 7 * ASSETCHAINS_BLOCKTIME;
|
hush_changeblocktime();
|
||||||
Params.GetConsensus().nPowTargetSpacing = ASSETCHAINS_BLOCKTIME;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool fExpensiveChecks = true;
|
bool fExpensiveChecks = true;
|
||||||
@@ -3992,8 +3991,7 @@ void static UpdateTip(CBlockIndex *pindexNew) {
|
|||||||
if (ASSETCHAINS_BLOCKTIME != 75 && (chainActive.Height() >= nFirstHalvingHeight)) {
|
if (ASSETCHAINS_BLOCKTIME != 75 && (chainActive.Height() >= nFirstHalvingHeight)) {
|
||||||
LogPrintf("%s: Blocktime halving to 75s at height %d!\n",__func__,chainActive.Height());
|
LogPrintf("%s: Blocktime halving to 75s at height %d!\n",__func__,chainActive.Height());
|
||||||
ASSETCHAINS_BLOCKTIME = 75;
|
ASSETCHAINS_BLOCKTIME = 75;
|
||||||
Params.GetConsensus().nMaxFutureBlockTime = 7 * ASSETCHAINS_BLOCKTIME;
|
hush_changeblocktime();
|
||||||
Params.GetConsensus().nPowTargetSpacing = ASSETCHAINS_BLOCKTIME;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user