mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
added two fields in settings/people to setup the thresholds to decide between neutral and remotely positive/negative reputation
This commit is contained in:
parent
da881e1f5b
commit
fb733916ef
@ -73,8 +73,13 @@ public:
|
|||||||
virtual float nodeAutoBanIdentitiesLimit() =0;
|
virtual float nodeAutoBanIdentitiesLimit() =0;
|
||||||
virtual void setNodeAutoBanIdentitiesLimit(float f) =0;
|
virtual void setNodeAutoBanIdentitiesLimit(float f) =0;
|
||||||
|
|
||||||
// This one is a proxy designed to allow fast checking of a GXS id.
|
virtual uint32_t thresholdForRemotelyNegativeReputation()=0;
|
||||||
// it basically returns true if assessment is not ASSESSMENT_OK
|
virtual uint32_t thresholdForRemotelyPositiveReputation()=0;
|
||||||
|
virtual void setThresholdForRemotelyNegativeReputation(uint32_t thresh)=0;
|
||||||
|
virtual void setThresholdForRemotelyPositiveReputation(uint32_t thresh)=0;
|
||||||
|
|
||||||
|
// This one is a proxy designed to allow fast checking of a GXS id.
|
||||||
|
// it basically returns true if assessment is not ASSESSMENT_OK
|
||||||
|
|
||||||
virtual bool isIdentityBanned(const RsGxsId& id) =0;
|
virtual bool isIdentityBanned(const RsGxsId& id) =0;
|
||||||
|
|
||||||
|
@ -141,6 +141,9 @@ static const uint32_t BANNED_NODES_UPDATE_DELAY = 313 ; // update
|
|||||||
static const uint32_t REPUTATION_INFO_KEEP_DELAY = 86400*35; // remove old reputation info 5 days after last usage limit, in case the ID would come back..
|
static const uint32_t REPUTATION_INFO_KEEP_DELAY = 86400*35; // remove old reputation info 5 days after last usage limit, in case the ID would come back..
|
||||||
static const uint32_t BANNED_NODES_INACTIVITY_KEEP = 86400*60; // remove all info about banned nodes after 2 months of inactivity
|
static const uint32_t BANNED_NODES_INACTIVITY_KEEP = 86400*60; // remove all info about banned nodes after 2 months of inactivity
|
||||||
|
|
||||||
|
static const uint32_t REPUTATION_DEFAULT_MIN_VOTES_FOR_REMOTELY_POSITIVE = 1; // min difference in votes that makes friends opinion globally positive
|
||||||
|
static const uint32_t REPUTATION_DEFAULT_MIN_VOTES_FOR_REMOTELY_NEGATIVE = 1; // min difference in votes that makes friends opinion globally negative
|
||||||
|
|
||||||
p3GxsReputation::p3GxsReputation(p3LinkMgr *lm)
|
p3GxsReputation::p3GxsReputation(p3LinkMgr *lm)
|
||||||
:p3Service(), p3Config(),
|
:p3Service(), p3Config(),
|
||||||
mReputationMtx("p3GxsReputation"), mLinkMgr(lm)
|
mReputationMtx("p3GxsReputation"), mLinkMgr(lm)
|
||||||
@ -159,6 +162,8 @@ p3GxsReputation::p3GxsReputation(p3LinkMgr *lm)
|
|||||||
|
|
||||||
mAutoBanIdentitiesLimit = REPUTATION_ASSESSMENT_THRESHOLD_X1;
|
mAutoBanIdentitiesLimit = REPUTATION_ASSESSMENT_THRESHOLD_X1;
|
||||||
mAutoSetPositiveOptionToContacts = true; // default
|
mAutoSetPositiveOptionToContacts = true; // default
|
||||||
|
mMinVotesForRemotelyPositive = REPUTATION_DEFAULT_MIN_VOTES_FOR_REMOTELY_POSITIVE;
|
||||||
|
mMinVotesForRemotelyNegative = REPUTATION_DEFAULT_MIN_VOTES_FOR_REMOTELY_NEGATIVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string GXS_REPUTATION_APP_NAME = "gxsreputation";
|
const std::string GXS_REPUTATION_APP_NAME = "gxsreputation";
|
||||||
@ -871,9 +876,9 @@ bool p3GxsReputation::getReputationInfo(const RsGxsId& gxsid, const RsPgpId& own
|
|||||||
}
|
}
|
||||||
// 2 - now, our own opinion is neutral, which means we rely on what our friends tell
|
// 2 - now, our own opinion is neutral, which means we rely on what our friends tell
|
||||||
|
|
||||||
if(info.mFriendsPositiveVotes > info.mFriendsNegativeVotes)
|
if(info.mFriendsPositiveVotes >= info.mFriendsNegativeVotes + mMinVotesForRemotelyPositive)
|
||||||
info.mOverallReputationLevel = RsReputations::REPUTATION_REMOTELY_POSITIVE ;
|
info.mOverallReputationLevel = RsReputations::REPUTATION_REMOTELY_POSITIVE ;
|
||||||
else if(info.mFriendsPositiveVotes < info.mFriendsNegativeVotes)
|
else if(info.mFriendsPositiveVotes + mMinVotesForRemotelyNegative <= info.mFriendsNegativeVotes)
|
||||||
info.mOverallReputationLevel = RsReputations::REPUTATION_REMOTELY_NEGATIVE ;
|
info.mOverallReputationLevel = RsReputations::REPUTATION_REMOTELY_NEGATIVE ;
|
||||||
else
|
else
|
||||||
info.mOverallReputationLevel = RsReputations::REPUTATION_NEUTRAL ;
|
info.mOverallReputationLevel = RsReputations::REPUTATION_NEUTRAL ;
|
||||||
@ -885,6 +890,36 @@ bool p3GxsReputation::getReputationInfo(const RsGxsId& gxsid, const RsPgpId& own
|
|||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t p3GxsReputation::thresholdForRemotelyNegativeReputation()
|
||||||
|
{
|
||||||
|
RsStackMutex stack(mReputationMtx); /****** LOCKED MUTEX *******/
|
||||||
|
return mMinVotesForRemotelyNegative ;
|
||||||
|
}
|
||||||
|
uint32_t p3GxsReputation::thresholdForRemotelyPositiveReputation()
|
||||||
|
{
|
||||||
|
RsStackMutex stack(mReputationMtx); /****** LOCKED MUTEX *******/
|
||||||
|
return mMinVotesForRemotelyPositive ;
|
||||||
|
}
|
||||||
|
void p3GxsReputation::setThresholdForRemotelyPositiveReputation(uint32_t thresh)
|
||||||
|
{
|
||||||
|
RsStackMutex stack(mReputationMtx); /****** LOCKED MUTEX *******/
|
||||||
|
if(mMinVotesForRemotelyPositive == thresh || thresh==0)
|
||||||
|
return ;
|
||||||
|
|
||||||
|
mMinVotesForRemotelyPositive = thresh ;
|
||||||
|
IndicateConfigChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void p3GxsReputation::setThresholdForRemotelyNegativeReputation(uint32_t thresh)
|
||||||
|
{
|
||||||
|
RsStackMutex stack(mReputationMtx); /****** LOCKED MUTEX *******/
|
||||||
|
if(mMinVotesForRemotelyNegative == thresh || thresh==0)
|
||||||
|
return ;
|
||||||
|
|
||||||
|
mMinVotesForRemotelyNegative = thresh ;
|
||||||
|
IndicateConfigChanged();
|
||||||
|
}
|
||||||
|
|
||||||
void p3GxsReputation::banNode(const RsPgpId& id,bool b)
|
void p3GxsReputation::banNode(const RsPgpId& id,bool b)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mReputationMtx); /****** LOCKED MUTEX *******/
|
RsStackMutex stack(mReputationMtx); /****** LOCKED MUTEX *******/
|
||||||
|
@ -120,6 +120,11 @@ public:
|
|||||||
virtual float nodeAutoBanIdentitiesLimit() ;
|
virtual float nodeAutoBanIdentitiesLimit() ;
|
||||||
virtual void setNodeAutoBanIdentitiesLimit(float f) ;
|
virtual void setNodeAutoBanIdentitiesLimit(float f) ;
|
||||||
|
|
||||||
|
uint32_t thresholdForRemotelyNegativeReputation();
|
||||||
|
uint32_t thresholdForRemotelyPositiveReputation();
|
||||||
|
void setThresholdForRemotelyNegativeReputation(uint32_t thresh);
|
||||||
|
void setThresholdForRemotelyPositiveReputation(uint32_t thresh);
|
||||||
|
|
||||||
/***** overloaded from p3Service *****/
|
/***** overloaded from p3Service *****/
|
||||||
virtual int tick();
|
virtual int tick();
|
||||||
virtual int status();
|
virtual int status();
|
||||||
@ -185,6 +190,9 @@ private:
|
|||||||
std::set<RsGxsId> mPerNodeBannedIdsProxy ;
|
std::set<RsGxsId> mPerNodeBannedIdsProxy ;
|
||||||
//uint32_t mPgpAutoBanThreshold ;
|
//uint32_t mPgpAutoBanThreshold ;
|
||||||
bool mBannedNodesProxyNeedsUpdate ;
|
bool mBannedNodesProxyNeedsUpdate ;
|
||||||
|
|
||||||
|
uint32_t mMinVotesForRemotelyPositive ;
|
||||||
|
uint32_t mMinVotesForRemotelyNegative ;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //SERVICE_RSGXSREPUTATION_HEADER
|
#endif //SERVICE_RSGXSREPUTATION_HEADER
|
||||||
|
@ -42,7 +42,8 @@ bool PeoplePage::save(QString &/*errmsg*/)
|
|||||||
else
|
else
|
||||||
rsReputations->setNodeAutoPositiveOpinionForContacts(false) ;
|
rsReputations->setNodeAutoPositiveOpinionForContacts(false) ;
|
||||||
|
|
||||||
rsReputations->setNodeAutoBanIdentitiesLimit(ui.autoBanIdentitiesLimit_SB->value());
|
rsReputations->setThresholdForRemotelyPositiveReputation(ui.thresholdForPositive_SB->value());
|
||||||
|
rsReputations->setThresholdForRemotelyNegativeReputation(ui.thresholdForNegative_SB->value());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -51,8 +52,10 @@ bool PeoplePage::save(QString &/*errmsg*/)
|
|||||||
void PeoplePage::load()
|
void PeoplePage::load()
|
||||||
{
|
{
|
||||||
bool auto_positive_contacts = rsReputations->nodeAutoPositiveOpinionForContacts() ;
|
bool auto_positive_contacts = rsReputations->nodeAutoPositiveOpinionForContacts() ;
|
||||||
float node_auto_ban_identities_limit = rsReputations->nodeAutoBanIdentitiesLimit();
|
uint32_t threshold_for_positive = rsReputations->thresholdForRemotelyPositiveReputation();
|
||||||
|
uint32_t threshold_for_negative = rsReputations->thresholdForRemotelyNegativeReputation();
|
||||||
|
|
||||||
ui.autoPositiveOpinion_CB->setChecked(auto_positive_contacts);
|
ui.autoPositiveOpinion_CB->setChecked(auto_positive_contacts);
|
||||||
ui.autoBanIdentitiesLimit_SB->setValue(node_auto_ban_identities_limit);
|
ui.thresholdForPositive_SB->setValue(threshold_for_positive);
|
||||||
|
ui.thresholdForNegative_SB->setValue(threshold_for_negative);
|
||||||
}
|
}
|
||||||
|
@ -10,13 +10,13 @@
|
|||||||
<height>441</height>
|
<height>441</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="generalGroupBox">
|
<widget class="QGroupBox" name="generalGroupBox">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Identities handling</string>
|
<string>Identities handling</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="autoPositiveOpinion_CB">
|
<widget class="QCheckBox" name="autoPositiveOpinion_CB">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
@ -31,30 +31,44 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item>
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="label_2">
|
<widget class="QLabel" name="label_3">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Friend average opinion below which identities are banned:</string>
|
<string>Difference in votes to make friends globally negative:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item row="1" column="2">
|
||||||
<widget class="QDoubleSpinBox" name="autoBanIdentitiesLimit_SB">
|
<widget class="QSpinBox" name="thresholdForNegative_SB">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string><html><head/><body><p>The default value of -0.6 needs 3 to 4 friends to set a negative opinion in order for that identity to be banned at your own node. This is a pretty conservative value. If you want to more easily get rid of banned identities, set the value to e.g. -0.2</p></body></html></string>
|
<string><html><head/><body><p>The default value of -0.6 needs 3 to 4 friends to set a negative opinion in order for that identity to be banned at your own node. This is a pretty conservative value. If you want to more easily get rid of banned identities, set the value to e.g. -0.2</p></body></html></string>
|
||||||
</property>
|
</property>
|
||||||
<property name="minimum">
|
<property name="minimum">
|
||||||
<double>-1.000000000000000</double>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximum">
|
<property name="maximum">
|
||||||
<double>-0.010000000000000</double>
|
<number>100</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="singleStep">
|
</widget>
|
||||||
<double>0.010000000000000</double>
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<widget class="QSpinBox" name="thresholdForPositive_SB">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string><html><head/><body><p>The default value of -0.6 needs 3 to 4 friends to set a negative opinion in order for that identity to be banned at your own node. This is a pretty conservative value. If you want to more easily get rid of banned identities, set the value to e.g. -0.2</p></body></html></string>
|
||||||
</property>
|
</property>
|
||||||
<property name="value">
|
<property name="minimum">
|
||||||
<double>-0.600000000000000</double>
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>100</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>Difference in votes to make friends globally positive:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
Loading…
Reference in New Issue
Block a user