Skip to content

Commit

Permalink
Mining: Toggle ascending via Gov var (#3041)
Browse files Browse the repository at this point in the history
* Mining: Toggle ascending via Gov var

* simplify check

* fmt

---------

Co-authored-by: Prasanna Loganathar <[email protected]>
  • Loading branch information
Bushstar and prasannavl authored Sep 10, 2024
1 parent 87dec63 commit ac6dfea
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1204,6 +1204,7 @@ namespace pos {
uint32_t mintedBlocks{};
int64_t blockTime{};
int64_t subNodeBlockTime{};
bool ascendingEnabled{};

{
LOCK(cs_main);
Expand All @@ -1221,6 +1222,10 @@ namespace pos {
}
subNodeBlockTime =
pcustomcsview->GetBlockTimes(operatorId, blockHeight, creationHeight, *timeLock)[subNode];
const auto attributes = pcustomcsview->GetAttributes();
CDataStructureV0 enabledKey{AttributeTypes::Param, ParamIDs::Feature, DFIPKeys::AscendingBlockTime};
ascendingEnabled =
attributes->GetValue(enabledKey, false) || gArgs.GetBoolArg("-ascendingstaketime", false);
}

auto nBits = pos::GetNextWorkRequired(tip, blockTime, chainparams.GetConsensus());
Expand All @@ -1235,8 +1240,7 @@ namespace pos {
nLastCoinStakeSearchTime = tip->GetMedianTimePast() + 1;
}
} else {
if (gArgs.GetBoolArg("-ascendingstaketime", false) ||
blockHeight >= static_cast<int64_t>(Params().GetConsensus().DF24Height)) {
if (ascendingEnabled) {
// Set time to last block time. New blocks must be after the last block.
nLastCoinStakeSearchTime = tip->GetBlockTime();
} else {
Expand Down

0 comments on commit ac6dfea

Please sign in to comment.