Use the new uptime code. Replace slow, non-monotonic 'time(NULL)' calls

with fast, almost-always-monotonic 'upTime()' calls.
This commit is contained in:
JoelKatz
2013-02-05 22:31:26 -08:00
parent 8c36646b8c
commit 1808454983
10 changed files with 44 additions and 35 deletions

View File

@@ -4,6 +4,8 @@
DECLARE_INSTANCE(Suppression);
extern int upTime();
Suppression& SuppressionTable::findCreateEntry(const uint256& index, bool& created)
{
boost::unordered_map<uint256, Suppression>::iterator fit = mSuppressionMap.find(index);
@@ -15,11 +17,11 @@ Suppression& SuppressionTable::findCreateEntry(const uint256& index, bool& creat
}
created = true;
time_t now = time(NULL);
time_t expireTime = now - mHoldTime;
int now = upTime();
int expireTime = now - mHoldTime;
// See if any supressions need to be expired
std::map< time_t, std::list<uint256> >::iterator it = mSuppressionTimes.begin();
std::map< int, std::list<uint256> >::iterator it = mSuppressionTimes.begin();
if ((it != mSuppressionTimes.end()) && (it->first <= expireTime))
{
BOOST_FOREACH(const uint256& lit, it->second)