From 441b164c730da256328e9b3a700e516fb13d0a47 Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 13 Oct 2015 21:54:52 -0400 Subject: [PATCH] fixed small bugs in average friend reputation display --- libretroshare/src/services/p3gxsreputation.cc | 11 +++++------ libretroshare/src/services/p3gxsreputation.h | 2 +- retroshare-gui/src/gui/Identity/IdDialog.cpp | 4 ++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/libretroshare/src/services/p3gxsreputation.cc b/libretroshare/src/services/p3gxsreputation.cc index 2bcdf2498..e84500280 100644 --- a/libretroshare/src/services/p3gxsreputation.cc +++ b/libretroshare/src/services/p3gxsreputation.cc @@ -776,10 +776,10 @@ bool p3GxsReputation::loadReputationSet(RsGxsReputationSetItem *item, const std: // if dropping entries has changed the score -> must update. - float old_reputation = reputation.mReputation ; + //float old_reputation = reputation.mReputation ; + //mUpdatedReputations.insert(gxsId) ; - if(old_reputation != reputation.updateReputation(mAverageActiveFriends)) - mUpdatedReputations.insert(gxsId) ; + reputation.updateReputation(mAverageActiveFriends) ; mUpdated.insert(std::make_pair(reputation.mOwnOpinionTs, gxsId)); return true; @@ -888,13 +888,14 @@ int p3GxsReputation::sendReputationRequest(RsPeerId peerid) return 1; } -float Reputation::updateReputation(uint32_t average_active_friends) +void Reputation::updateReputation(uint32_t average_active_friends) { // the calculation of reputation makes the whole thing int friend_total = 0; // accounts for all friends. Neutral opinions count for 1-1=0 + // because the average is performed over only accessible peers (not the total number) we need to shift to 1 for(std::map::const_iterator it(mOpinions.begin());it!=mOpinions.end();++it) friend_total += it->second - 1; @@ -908,8 +909,6 @@ float Reputation::updateReputation(uint32_t average_active_friends) mReputation = mFriendAverage ; else mReputation = (float)mOwnOpinion ; - - return float(mOwnOpinion) ; } void p3GxsReputation::debug_print() diff --git a/libretroshare/src/services/p3gxsreputation.h b/libretroshare/src/services/p3gxsreputation.h index 076e14003..26beca518 100644 --- a/libretroshare/src/services/p3gxsreputation.h +++ b/libretroshare/src/services/p3gxsreputation.h @@ -64,7 +64,7 @@ public: Reputation(const RsGxsId& about) :mOwnOpinion(RsReputations::OPINION_NEUTRAL), mOwnOpinionTs(0), mReputation(RsReputations::OPINION_NEUTRAL) { } - float updateReputation(uint32_t average_active_friends); + void updateReputation(uint32_t average_active_friends); std::map mOpinions; int32_t mOwnOpinion; diff --git a/retroshare-gui/src/gui/Identity/IdDialog.cpp b/retroshare-gui/src/gui/Identity/IdDialog.cpp index 2d26c55b4..0f65fc3cd 100644 --- a/retroshare-gui/src/gui/Identity/IdDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdDialog.cpp @@ -680,9 +680,9 @@ void IdDialog::insertIdDetails(uint32_t token) RsReputations::ReputationInfo info ; rsReputations->getReputationInfo(RsGxsId(data.mMeta.mGroupId),info) ; - ui->neighborNodesOpinion_TF->setText(QString::number(info.mOverallReputationScore-1.0f)); + ui->neighborNodesOpinion_TF->setText(QString::number(info.mFriendAverage - 1.0f)); - ui->overallOpinion_TF->setText(QString::number(info.mOverallReputationScore-1.0f) +" ("+ + ui->overallOpinion_TF->setText(QString::number(info.mOverallReputationScore - 1.0f) +" ("+ ((info.mAssessment == RsReputations::ASSESSMENT_OK)? tr("OK") : tr("Banned")) +")" ) ; switch(info.mOwnOpinion)