@@ -14,12 +14,6 @@ using namespace NN;
14
14
using LogFlags = BCLog::LogFlags;
15
15
16
16
namespace {
17
- // !
18
- // ! \brief Number of days that the tally scans backward from to calculate
19
- // ! the average network payment.
20
- // !
21
- constexpr size_t TALLY_DAYS = 14 ;
22
-
23
17
// !
24
18
// ! \brief Set the correct CPID from the block claim when the block index
25
19
// ! contains a zero CPID.
@@ -55,25 +49,27 @@ void RepairZeroCpidIndex(CBlockIndex* const pindex)
55
49
}
56
50
}
57
51
58
- // !
59
- // ! \brief Round a value to intervals of 0.025.
60
- // !
61
- // ! Used to calculate the network magnitude unit.
62
- // !
63
- double SnapToGrid (double d)
64
- {
65
- double dDither = .04 ;
66
- double dOut = RoundFromString (RoundToString (d * dDither, 3 ), 3 ) / dDither;
67
- return dOut;
68
- }
69
-
70
52
// !
71
53
// ! \brief Contains the two-week network average tally used to produce the
72
- // ! magnitude unit for research age reward calculations.
54
+ // ! magnitude unit for legacy research age reward calculations (version 10
55
+ // ! blocks and below).
56
+ // !
57
+ // ! Before block version 11, the network used a feedback filter to limit the
58
+ // ! total research reward generated over a rolling two week window. To scale
59
+ // ! rewards accordingly, the magnitude unit acts as a multiplier and changes
60
+ // ! in response to the amount of research rewards minted over the two weeks.
61
+ // ! This class holds state for the parameters that produce a magnitude units
62
+ // ! at a point in time.
73
63
// !
74
64
class NetworkTally
75
65
{
76
66
public:
67
+ // !
68
+ // ! \brief Number of days that the tally scans backward from to calculate
69
+ // ! the average network payment.
70
+ // !
71
+ static constexpr size_t TALLY_DAYS = 14 ;
72
+
77
73
// !
78
74
// ! \brief Get the maximum network-wide research reward amount per day.
79
75
// !
@@ -137,6 +133,16 @@ class NetworkTally
137
133
private:
138
134
uint32_t m_total_magnitude = 0 ; // !< Sum of the magnitude of all CPIDs.
139
135
double m_two_week_research_subsidy = 0 ; // !< Sum of research subsidy payments.
136
+
137
+ // !
138
+ // ! \brief Round a magnitude unit value to intervals of 0.025.
139
+ // !
140
+ static double SnapToGrid (double d)
141
+ {
142
+ double dDither = .04 ;
143
+ double dOut = RoundFromString (RoundToString (d * dDither, 3 ), 3 ) / dDither;
144
+ return dOut;
145
+ }
140
146
}; // NetworkTally
141
147
142
148
// !
@@ -380,7 +386,7 @@ class ResearcherTally
380
386
}; // ResearcherTally
381
387
382
388
ResearcherTally g_researcher_tally; // !< Tracks lifetime research rewards.
383
- NetworkTally g_network_tally; // !< Tracks two-week network averages.
389
+ NetworkTally g_network_tally; // !< Tracks legacy two-week network averages.
384
390
385
391
} // Anonymous namespace
386
392
@@ -433,17 +439,17 @@ bool Tally::ActivateSnapshotAccrual(const CBlockIndex* const pindex)
433
439
Quorum::CurrentSuperblock ());
434
440
}
435
441
436
- bool Tally::IsTrigger (const uint64_t height)
442
+ bool Tally::IsLegacyTrigger (const uint64_t height)
437
443
{
438
444
return height % TALLY_GRANULARITY == 0 ;
439
445
}
440
446
441
- CBlockIndex* Tally::FindTrigger (CBlockIndex* pindex)
447
+ CBlockIndex* Tally::FindLegacyTrigger (CBlockIndex* pindex)
442
448
{
443
449
// Scan backwards until we find one where accepting it would
444
450
// trigger a tally.
445
451
for (;
446
- pindex && pindex->pprev && !IsTrigger (pindex->nHeight );
452
+ pindex && pindex->pprev && !IsLegacyTrigger (pindex->nHeight );
447
453
pindex = pindex->pprev );
448
454
449
455
return pindex;
@@ -582,7 +588,7 @@ void Tally::LegacyRecount(const CBlockIndex* pindex)
582
588
LogPrint (LogFlags::TALLY, " Tally::LegacyRecount(%" PRId64 " )" , pindex->nHeight );
583
589
584
590
const int64_t consensus_depth = pindex->nHeight - CONSENSUS_LOOKBACK;
585
- const int64_t lookback_depth = BLOCKS_PER_DAY * TALLY_DAYS;
591
+ const int64_t lookback_depth = BLOCKS_PER_DAY * NetworkTally:: TALLY_DAYS;
586
592
587
593
int64_t max_depth = consensus_depth - (consensus_depth % TALLY_GRANULARITY);
588
594
int64_t min_depth = max_depth - lookback_depth;
0 commit comments