Browse Source

Block time halving at height 340000

pull/121/head
Duke Leto 4 years ago
parent
commit
bb6565d966
  1. 22
      src/main.cpp
  2. 5
      src/pow.cpp

22
src/main.cpp

@ -3350,6 +3350,8 @@ static int64_t nTimeTotal = 0;
bool FindBlockPos(int32_t tmpflag,CValidationState &state, CDiskBlockPos &pos, unsigned int nAddSize, unsigned int nHeight, uint64_t nTime, bool fKnown = false);
bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBlockIndex *pindexNew, const CDiskBlockPos& pos);
int32_t nFirstHalvingHeight = 340000;
bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pindex, CCoinsViewCache& view, bool fJustCheck,bool fCheckPOW)
{
CDiskBlockPos blockPos;
@ -3362,15 +3364,20 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
AssertLockHeld(cs_main);
bool ishush3 = strncmp(ASSETCHAINS_SYMBOL, "HUSH3",5) == 0 ? true : false;
// At startup, HUSH3 doesn't know a block height yet and so we must wait until
// connecting a block to set our private/blocktime flags, which are height-dependent
if(!ASSETCHAINS_PRIVATE && ishush3) {
unsigned int nHeight = pindex->GetHeight();
if(nHeight >= 340000) {
// At startup, HUSH3 doesn't know a block height yet and so we must wait until
// connecting a block
fprintf(stderr, "%s: Going full z2z at height %d!\n",__func__,nHeight);
if(nHeight >= nFirstHalvingHeight) {
fprintf(stderr, "%s: Going full z2z at height %d!\n",__func__,pindex->GetHeight());
ASSETCHAINS_PRIVATE = 1;
}
}
if (ishush3 && (ASSETCHAINS_BLOCKTIME != 75) && (chainActive.Height() >= nFirstHalvingHeight)) {
LogPrintf("%s: Blocktime halving to 75s at height %d!\n",__func__,pindex->GetHeight());
ASSETCHAINS_BLOCKTIME = 75;
}
bool fExpensiveChecks = true;
if (fCheckpointsEnabled) {
@ -3968,6 +3975,13 @@ void static UpdateTip(CBlockIndex *pindexNew) {
progress = (longestchain > 0 ) ? (double) chainActive.Height() / longestchain : 1.0;
}
if(ishush3) {
if (ASSETCHAINS_BLOCKTIME != 75 && (chainActive.Height() >= nFirstHalvingHeight)) {
LogPrintf("%s: Blocktime halving to 75s at height %d!\n",__func__,chainActive.Height());
ASSETCHAINS_BLOCKTIME = 75;
}
}
LogPrintf("%s: new best=%s height=%d log2_work=%.8g tx=%lu date=%s progress=%f cache=%.1fMiB(%utx)\n", __func__,
chainActive.LastTip()->GetBlockHash().ToString(), chainActive.Height(),
log(chainActive.Tip()->chainPower.chainWork.getdouble())/log(2.0),

5
src/pow.cpp

@ -1,6 +1,6 @@
// Copyright (c) 2009-2010 Satoshi Nakamoto
// Copyright (c) 2009-2014 The Bitcoin Core developers
// Copyright (c) 2019 The Hush 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.
@ -298,6 +298,9 @@ arith_uint256 zawy_TSA_EMA(int32_t height,int32_t tipdiff,arith_uint256 prevTarg
unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params)
{
if (pindexLast->GetHeight() == 340000) {
LogPrintf("%s: Using blocktime=%d\n",__func__,ASSETCHAINS_BLOCKTIME);
}
if (ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH && ASSETCHAINS_STAKED == 0)
return lwmaGetNextWorkRequired(pindexLast, pblock, params);

Loading…
Cancel
Save