@@ -203,7 +203,7 @@ namespace cryptonote {
203203 // See https://github.com/zawy12/difficulty-algorithms/issues/3 for other algos.
204204 // Do not use "if solvetime < 0 then solvetime = 1" which allows a catastrophic exploit.
205205 // T= target_solvetime;
206- // N=45, 55, 70, 95, 140 for T=600, 240, 120, 90, and 60 respectively.
206+ // N=45, 55, 70, 90, 120 for T=600, 240, 120, 90, and 60
207207
208208 const int64_t T = static_cast <int64_t >(target_seconds);
209209 size_t N = DIFFICULTY_WINDOW_V2;
@@ -221,6 +221,7 @@ namespace cryptonote {
221221 else if (n < N+1 ) { N=n-1 ; }
222222
223223 // To get an average solvetime to within +/- ~0.1%, use an adjustment factor.
224+ // adjust=0.99 for 90 < N < 130
224225 const double adjust = 0.998 ;
225226 // The divisor k normalizes LWMA.
226227 const double k = N * (N + 1 ) / 2 ;
@@ -232,7 +233,7 @@ namespace cryptonote {
232233 // Loop through N most recent blocks.
233234 for (size_t i = 1 ; i <= N; i++) {
234235 solveTime = static_cast <int64_t >(timestamps[i]) - static_cast <int64_t >(timestamps[i - 1 ]);
235- solveTime = std::min<int64_t >((T * 7 ), std::max<int64_t >(solveTime, (-6 * T)));
236+ solveTime = std::min<int64_t >((T * 7 ), std::max<int64_t >(solveTime, (-7 * T)));
236237 difficulty = cumulative_difficulties[i] - cumulative_difficulties[i - 1 ];
237238 LWMA += solveTime * i / k;
238239 sum_inverse_D += 1 / static_cast <double >(difficulty);
0 commit comments