diff --git a/src/gridcoin/voting/poll.cpp b/src/gridcoin/voting/poll.cpp index 7300dacf69..8fcff589a5 100644 --- a/src/gridcoin/voting/poll.cpp +++ b/src/gridcoin/voting/poll.cpp @@ -215,15 +215,20 @@ int64_t Poll::Expiration() const return m_timestamp + (m_duration_days * 86400); } -Fraction Poll::ResolveMagnitudeWeightFactor() const +Fraction Poll::ResolveMagnitudeWeightFactor(CBlockIndex *index) const { Fraction magnitude_weight_factor = Params().GetConsensus().DefaultMagnitudeWeightFactor; - // Find the current protocol entry value for Magnitude Weight Factor, if it exists. + // Before V13 magnitude weight factor is 1 / 5.67. + if (!IsV13Enabled(index->nHeight)) { + return Fraction(100, 567); + } + + // Find the current protocol entry value for Magnitude Weight Factor, if it exists. ProtocolEntryOption protocol_entry = GetProtocolRegistry().TryLastBeforeTimestamp("magnitudeweightfactor", m_timestamp); - // If their is an entry prior or equal in timestemp to the start of the poll and it is active then set the magnitude weight - // factor to that value. If the last entry is not active (i.e. deleted), then leave at the default. + // If their is an entry prior or equal in timestemp to the start of the poll and it is active then set the magnitude weight + // factor to that value. If the last entry is not active (i.e. deleted), then leave at the default. if (protocol_entry != nullptr && protocol_entry->m_status == ProtocolEntryStatus::ACTIVE) { magnitude_weight_factor = Fraction().FromString(protocol_entry->m_value); } diff --git a/src/gridcoin/voting/poll.h b/src/gridcoin/voting/poll.h index 6acb122d40..f88044eea6 100644 --- a/src/gridcoin/voting/poll.h +++ b/src/gridcoin/voting/poll.h @@ -512,9 +512,11 @@ class Poll //! \brief Fetch the applicable magnitude factor for the poll. This is the magnitude factor of the last entry in the //! protocol registry database that has a timestamp at or before the poll start timestamp. //! + //! \param index CBlockIndex of block containing poll transaction (poll start). + //! //! \return Fraction Magnitude factor expressed as a Fraction. //! - Fraction ResolveMagnitudeWeightFactor() const; + Fraction ResolveMagnitudeWeightFactor(CBlockIndex* index) const; //! //! \brief Get the set of possible answers to the poll. diff --git a/src/gridcoin/voting/registry.cpp b/src/gridcoin/voting/registry.cpp index 3a4df32c5a..b79c2652c3 100644 --- a/src/gridcoin/voting/registry.cpp +++ b/src/gridcoin/voting/registry.cpp @@ -353,7 +353,7 @@ PollOption PollReference::TryReadFromDisk(CTxDB& txdb) const // This is a critical initialization, because the magnitude weight factor is only stored // in memory and is not serialized. - payload.m_poll.m_magnitude_weight_factor = payload.m_poll.ResolveMagnitudeWeightFactor(); + payload.m_poll.m_magnitude_weight_factor = payload.m_poll.ResolveMagnitudeWeightFactor(GetStartingBlockIndexPtr()); m_magnitude_weight_factor = payload.m_poll.m_magnitude_weight_factor; LogPrint(BCLog::LogFlags::VOTE, "INFO: %s: reference.m_timestamp = %" PRId64 " , poll.m_timestamp = %" PRId64 " , "