fixed a few bugs in the People tab

This commit is contained in:
csoler 2016-07-25 16:04:30 -04:00
parent 218977170c
commit f5e55e849b
4 changed files with 11 additions and 12 deletions

View File

@ -151,6 +151,7 @@ p3GxsReputation::p3GxsReputation(p3LinkMgr *lm)
mStoreTime = 0; mStoreTime = 0;
mReputationsUpdated = false; mReputationsUpdated = false;
mLastActiveFriendsUpdate = time(NULL) - 0.5*ACTIVE_FRIENDS_UPDATE_PERIOD; // avoids doing it too soon since the TS from rsIdentity needs to be loaded already mLastActiveFriendsUpdate = time(NULL) - 0.5*ACTIVE_FRIENDS_UPDATE_PERIOD; // avoids doing it too soon since the TS from rsIdentity needs to be loaded already
mLastIdentityFlagsUpdate = time(NULL) - 3;
mAverageActiveFriends = 0 ; mAverageActiveFriends = 0 ;
mLastBannedNodesUpdate = 0 ; mLastBannedNodesUpdate = 0 ;
@ -189,22 +190,18 @@ int p3GxsReputation::tick()
mLastActiveFriendsUpdate = now ; mLastActiveFriendsUpdate = now ;
} }
static time_t last_identity_flags_update = 0 ;
// no more than once per 5 second chunk. // no more than once per 5 second chunk.
if(now > IDENTITY_FLAGS_UPDATE_DELAY+last_identity_flags_update) if(now > IDENTITY_FLAGS_UPDATE_DELAY+mLastIdentityFlagsUpdate)
{ {
last_identity_flags_update = now ;
updateIdentityFlags() ; updateIdentityFlags() ;
mLastIdentityFlagsUpdate = now ;
} }
if(now > BANNED_NODES_UPDATE_DELAY+mLastBannedNodesUpdate) // 613 is not a multiple of 100, to avoid piling up work if(now > BANNED_NODES_UPDATE_DELAY+mLastBannedNodesUpdate) // 613 is not a multiple of 100, to avoid piling up work
{ {
mLastBannedNodesUpdate = now ;
updateIdentityFlags() ; // needed before updateBannedNodesList! updateIdentityFlags() ; // needed before updateBannedNodesList!
updateBannedNodesList(); updateBannedNodesList();
mLastBannedNodesUpdate = now ;
} }
#ifdef DEBUG_REPUTATION #ifdef DEBUG_REPUTATION
@ -241,7 +238,7 @@ void p3GxsReputation::setNodeAutoPositiveOpinionForContacts(bool b)
if(b != mAutoSetPositiveOptionToContacts) if(b != mAutoSetPositiveOptionToContacts)
{ {
mLastBannedNodesUpdate = 0 ; mLastIdentityFlagsUpdate = 0 ;
mAutoSetPositiveOptionToContacts = b ; mAutoSetPositiveOptionToContacts = b ;
IndicateConfigChanged() ; IndicateConfigChanged() ;
} }
@ -953,7 +950,7 @@ bool p3GxsReputation::saveList(bool& cleanup, std::list<RsItem*> &savelist)
vitem->tlvkvs.pairs.push_back(kv) ; vitem->tlvkvs.pairs.push_back(kv) ;
kv.key = "AUTO_BAN_IDENTITIES_THRESHOLD" ; kv.key = "AUTO_BAN_IDENTITIES_THRESHOLD" ;
rs_sprintf(kv.value, "%d", mAutoBanIdentitiesLimit); rs_sprintf(kv.value, "%f", mAutoBanIdentitiesLimit);
vitem->tlvkvs.pairs.push_back(kv) ; vitem->tlvkvs.pairs.push_back(kv) ;
kv.key = "AUTO_POSITIVE_CONTACTS" ; kv.key = "AUTO_POSITIVE_CONTACTS" ;
@ -1017,6 +1014,7 @@ bool p3GxsReputation::loadList(std::list<RsItem *>& loadList)
if(kit->key == "AUTO_BAN_IDENTITIES_THRESHOLD") if(kit->key == "AUTO_BAN_IDENTITIES_THRESHOLD")
{ {
float val ; float val ;
if (sscanf(kit->value.c_str(), "%f", &val) == 1) if (sscanf(kit->value.c_str(), "%f", &val) == 1)
{ {
mAutoBanIdentitiesLimit = val ; mAutoBanIdentitiesLimit = val ;

View File

@ -149,6 +149,7 @@ private:
time_t mRequestTime; time_t mRequestTime;
time_t mStoreTime; time_t mStoreTime;
time_t mLastBannedNodesUpdate ; time_t mLastBannedNodesUpdate ;
time_t mLastIdentityFlagsUpdate ;
bool mReputationsUpdated; bool mReputationsUpdated;
uint32_t mAverageActiveFriends ; uint32_t mAverageActiveFriends ;

View File

@ -42,7 +42,7 @@ bool PeoplePage::save(QString &/*errmsg*/)
else else
rsReputations->setNodeAutoBanThreshold(ui.identityBanThreshold_SB->value()) ; rsReputations->setNodeAutoBanThreshold(ui.identityBanThreshold_SB->value()) ;
if(!ui.autoPositiveOpinion_CB->isChecked()) if(ui.autoPositiveOpinion_CB->isChecked())
rsReputations->setNodeAutoPositiveOpinionForContacts(true) ; rsReputations->setNodeAutoPositiveOpinionForContacts(true) ;
else else
rsReputations->setNodeAutoPositiveOpinionForContacts(false) ; rsReputations->setNodeAutoPositiveOpinionForContacts(false) ;

View File

@ -64,10 +64,10 @@
<item> <item>
<widget class="QCheckBox" name="autoPositiveOpinion_CB"> <widget class="QCheckBox" name="autoPositiveOpinion_CB">
<property name="toolTip"> <property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Anyone in your contact list will automatically have a positive opinion. This allows to automatically raise reputations of used nodes. &lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string> <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Anyone in your contact list will automatically have a positive opinion if not set. This allows to automatically raise reputations of used nodes. &lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
<property name="text"> <property name="text">
<string>automatically give &quot;Positive&quot; option to my contacts</string> <string>automatically give &quot;Positive&quot; opinion to my contacts</string>
</property> </property>
<property name="checked"> <property name="checked">
<bool>true</bool> <bool>true</bool>