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) ;

View File

@ -14,7 +14,7 @@
<item>
<widget class="QGroupBox" name="generalGroupBox">
<property name="title">
<string>Identities handling</string>
<string>Reputation</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
@ -41,7 +41,7 @@
<string>Difference in votes to make friends globally negative:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
@ -80,7 +80,7 @@
<string>Difference in votes to make friends globally positive:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
@ -90,10 +90,10 @@
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>Delete banned identities after:</string>
<string>Delete banned identities after (0 means indefinitely):</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
@ -103,15 +103,18 @@
<enum>Qt::RightToLeft</enum>
</property>
<property name="text">
<string>Prevent re-loading previously banned identities for:</string>
<string>Reset reputation of banned identities after (0 means never):</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QSpinBox" name="deleteBannedIdentitiesAfter_SB">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Banned identities are not stamped and therefore lose activity. They get deleted automatically after a finit period of time.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="suffix">
<string> days</string>
</property>
@ -125,6 +128,9 @@
</item>
<item row="3" column="2">
<widget class="QSpinBox" name="preventReloadingBannedIdentitiesFor_SB">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;In order to prevent deleted banned IDs to come back because they are used in e.g. forums or channels, banned identities are kept in a list for some time. After that, they are &amp;quot;cleared&amp;quot; from the banning list, and will be downloaded again as unbanned if used in forus, chat rooms, etc.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="suffix">
<string> days</string>
</property>