mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-20 19:15:54 +00:00
DecayingSample::decay must always return with the time current.
This commit is contained in:
@@ -63,25 +63,24 @@ private:
|
|||||||
// Apply exponential decay based on the specified time.
|
// Apply exponential decay based on the specified time.
|
||||||
void decay (elapsed_type now)
|
void decay (elapsed_type now)
|
||||||
{
|
{
|
||||||
if (m_value == value_type())
|
if (now == m_when)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (m_value != value_type())
|
||||||
|
{
|
||||||
elapsed_type n (now - m_when);
|
elapsed_type n (now - m_when);
|
||||||
|
|
||||||
if (n == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// A span larger than four times the window decays the
|
// A span larger than four times the window decays the
|
||||||
// value to an insignificant amount so just reset it.
|
// value to an insignificant amount so just reset it.
|
||||||
//
|
//
|
||||||
if (n > 4 * Window)
|
if (n > 4 * Window)
|
||||||
{
|
|
||||||
m_value = value_type();
|
m_value = value_type();
|
||||||
return;
|
else
|
||||||
}
|
{
|
||||||
|
|
||||||
while (n--)
|
while (n--)
|
||||||
m_value -= (m_value + Window - 1) / Window;
|
m_value -= (m_value + Window - 1) / Window;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
m_when = now;
|
m_when = now;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user