mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 19:42:46 +01:00
fix: early EHF and buried EHF are indistinguish
This commit is contained in:
parent
8a05f0caaa
commit
7a7c9f12a4
@ -23,7 +23,7 @@
|
||||
#include <vector>
|
||||
|
||||
static const std::string MNEHF_REQUESTID_PREFIX = "mnhf";
|
||||
static const std::string DB_SIGNALS = "mnhf_s";
|
||||
static const std::string DB_SIGNALS_v2 = "mnhf_s2";
|
||||
|
||||
uint256 MNHFTxPayload::GetRequestId() const
|
||||
{
|
||||
@ -57,34 +57,32 @@ CMNHFManager::Signals CMNHFManager::GetSignalsStage(const CBlockIndex* const pin
|
||||
{
|
||||
if (!DeploymentActiveAfter(pindexPrev, Params().GetConsensus(), Consensus::DEPLOYMENT_V20)) return {};
|
||||
|
||||
Signals signals = GetForBlock(pindexPrev);
|
||||
Signals signals_tmp = GetForBlock(pindexPrev);
|
||||
|
||||
if (pindexPrev == nullptr) return {};
|
||||
const int height = pindexPrev->nHeight + 1;
|
||||
for (auto it = signals.begin(); it != signals.end(); ) {
|
||||
bool found{false};
|
||||
const auto signal_pindex = pindexPrev->GetAncestor(it->second);
|
||||
|
||||
Signals signals_ret;
|
||||
|
||||
for (auto signal : signals_tmp) {
|
||||
bool expired{false};
|
||||
const auto signal_pindex = pindexPrev->GetAncestor(signal.second);
|
||||
assert(signal_pindex != nullptr);
|
||||
const int64_t signal_time = signal_pindex->GetMedianTimePast();
|
||||
for (int index = 0; index < Consensus::MAX_VERSION_BITS_DEPLOYMENTS; ++index) {
|
||||
const auto& deployment = Params().GetConsensus().vDeployments[index];
|
||||
if (deployment.bit != it->first) continue;
|
||||
if (deployment.bit != signal.first) continue;
|
||||
if (signal_time < deployment.nStartTime) {
|
||||
// new deployment is using the same bit as the old one
|
||||
LogPrintf("CMNHFManager::GetSignalsStage: mnhf signal bit=%d height:%d is expired at height=%d\n", it->first, it->second, height);
|
||||
it = signals.erase(it);
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
if (!found) {
|
||||
// no deployment means we buried it and aren't using the same bit (yet)
|
||||
LogPrintf("CMNHFManager::GetSignalsStage: mnhf signal bit=%d height:%d is not known at height=%d\n", it->first, it->second, height);
|
||||
it = signals.erase(it);
|
||||
LogPrintf("CMNHFManager::GetSignalsStage: mnhf signal bit=%d height:%d is expired at height=%d\n", signal.first, signal.second, height);
|
||||
expired = true;
|
||||
}
|
||||
}
|
||||
return signals;
|
||||
if (!expired) {
|
||||
signals_ret.insert(signal);
|
||||
}
|
||||
}
|
||||
return signals_ret;
|
||||
}
|
||||
|
||||
bool MNHFTx::Verify(const llmq::CQuorumManager& qman, const uint256& quorumHash, const uint256& requestId, const uint256& msgHash, TxValidationState& state) const
|
||||
@ -287,6 +285,9 @@ CMNHFManager::Signals CMNHFManager::GetForBlock(const CBlockIndex* pindex)
|
||||
const Consensus::Params& consensusParams{Params().GetConsensus()};
|
||||
while (!to_calculate.empty()) {
|
||||
const CBlockIndex* pindex_top{to_calculate.top()};
|
||||
if (pindex_top->nHeight % 1000 == 0) {
|
||||
LogPrintf("re-index EHF signals at block %d\n", pindex_top->nHeight);
|
||||
}
|
||||
CBlock block;
|
||||
if (!ReadBlockFromDisk(block, pindex_top, consensusParams)) {
|
||||
throw std::runtime_error("failed-getehfforblock-read");
|
||||
@ -328,7 +329,7 @@ std::optional<CMNHFManager::Signals> CMNHFManager::GetFromCache(const CBlockInde
|
||||
return signals;
|
||||
}
|
||||
}
|
||||
if (m_evoDb.Read(std::make_pair(DB_SIGNALS, blockHash), signals)) {
|
||||
if (m_evoDb.Read(std::make_pair(DB_SIGNALS_v2, blockHash), signals)) {
|
||||
LOCK(cs_cache);
|
||||
mnhfCache.insert(blockHash, signals);
|
||||
return signals;
|
||||
@ -346,7 +347,7 @@ void CMNHFManager::AddToCache(const Signals& signals, const CBlockIndex* const p
|
||||
}
|
||||
if (!DeploymentActiveAt(*pindex, Params().GetConsensus(), Consensus::DEPLOYMENT_V20)) return;
|
||||
|
||||
m_evoDb.Write(std::make_pair(DB_SIGNALS, blockHash), signals);
|
||||
m_evoDb.Write(std::make_pair(DB_SIGNALS_v2, blockHash), signals);
|
||||
}
|
||||
|
||||
void CMNHFManager::AddSignal(const CBlockIndex* const pindex, int bit)
|
||||
|
Loading…
Reference in New Issue
Block a user