various small fixes in reputation/identity cleaning

This commit is contained in:
csoler 2017-01-12 21:14:36 +01:00
parent bd7f6aca99
commit 70a92a1c32
3 changed files with 34 additions and 13 deletions

View file

@ -166,6 +166,7 @@ p3GxsReputation::p3GxsReputation(p3LinkMgr *lm)
mLastReputationConfigSaved = 0;
mChanged = false ;
mMaxPreventReloadBannedIds = BANNED_NODES_INACTIVITY_KEEP_DEFAULT;
}
const std::string GXS_REPUTATION_APP_NAME = "gxsreputation";
@ -261,9 +262,9 @@ void p3GxsReputation::setRememberDeletedNodesThreshold(uint32_t days)
{
RsStackMutex stack(mReputationMtx); /****** LOCKED MUTEX *******/
if(mMaxPreventReloadBannedIds != days/86400)
if(mMaxPreventReloadBannedIds != days*86400)
{
mMaxPreventReloadBannedIds = days/86400 ;
mMaxPreventReloadBannedIds = days*86400 ;
IndicateConfigChanged();
}
}
@ -384,6 +385,14 @@ void p3GxsReputation::cleanup()
{
bool should_delete = false ;
if(it->second.mOwnOpinion == RsReputations::OPINION_NEGATIVE && mMaxPreventReloadBannedIds != 0 && it->second.mOwnOpinionTs + mMaxPreventReloadBannedIds < now)
{
#ifdef DEBUG_REPUTATION
std::cerr << " ID " << it->first << ": own is negative for more than " << mMaxPreventReloadBannedIds/86400 << " days. Reseting it!" << std::endl;
#endif
mChanged = true ;
}
// Delete slots with basically no information
if(it->second.mOpinions.empty() && it->second.mOwnOpinion == RsReputations::OPINION_NEUTRAL && (it->second.mOwnerNode.isNull()))

View file

@ -421,12 +421,18 @@ public:
time_t last_usage_ts = no_ts?0:(it->second.TS);
time_t max_keep_time ;
bool should_check = true ;
if(no_ts)
max_keep_time = 0 ;
else if(is_id_banned)
max_keep_time = mMaxKeepKeysBanned ;
else if(is_known_id)
else if(is_id_banned)
{
if(mMaxKeepKeysBanned == 0)
should_check = false ;
else
max_keep_time = mMaxKeepKeysBanned ;
}
else if(is_known_id)
max_keep_time = MAX_KEEP_KEYS_SIGNED_KNOWN ;
else if(is_signed_id)
max_keep_time = MAX_KEEP_KEYS_SIGNED ;
@ -435,7 +441,7 @@ public:
std::cerr << ". Max keep = " << max_keep_time/86400 << " days. Unused for " << (now - last_usage_ts + 86399)/86400 << " days " ;
if(now > last_usage_ts + max_keep_time)
if(should_check && now > last_usage_ts + max_keep_time)
{
std::cerr << " => delete " << std::endl;
ids_to_delete.push_back(gxs_id) ;