use rsReputations instead of rsIdentity for reputation calls. Suspended reputation vetting code which is not needed anymore

This commit is contained in:
csoler 2017-01-10 21:44:37 +01:00
parent 8d8453f9c0
commit a810ae9a74
11 changed files with 45 additions and 41 deletions

View File

@ -166,19 +166,17 @@ public:
class GixsReputation
{
public:
GixsReputation() : score(0) {}
RsGxsId id;
int score;
public:
GixsReputation() {}
RsGxsId id;
uint32_t reputation_level ;
};
class RsGixsReputation
{
public:
// get Reputation.
virtual bool haveReputation(const RsGxsId &id) = 0;
virtual bool loadReputation(const RsGxsId &id, const std::list<RsPeerId>& peers) = 0;
virtual bool getReputation(const RsGxsId &id, GixsReputation &rep) = 0;
virtual RsReputations::ReputationLevel overallReputationLevel(const RsGxsId& id) = 0;
};
@ -186,7 +184,6 @@ public:
class RsGxsIdExchange:
public RsGenExchange,
public RsGixsReputation,
public RsGixs
{
public:

View File

@ -3139,6 +3139,9 @@ void RsGxsNetService::runVetting()
RS_STACK_MUTEX(mNxsMutex) ;
#ifdef TO_BE_REMOVED
// Author response vetting is disabled since not used, as the reputations are currently not async-ed anymore.
std::vector<AuthorPending*>::iterator vit = mPendingResp.begin();
for(; vit != mPendingResp.end(); )
@ -3169,6 +3172,7 @@ void RsGxsNetService::runVetting()
}
}
#endif
// now lets do circle vetting

View File

@ -27,20 +27,13 @@
#include "pqi/p3servicecontrol.h"
#include "pgp/pgpauxutils.h"
const time_t AuthorPending::EXPIRY_PERIOD_OFFSET = 30; // 30 seconds
const int AuthorPending::MSG_PEND = 1;
const int AuthorPending::GRP_PEND = 2;
AuthorPending::AuthorPending(RsGixsReputation* rep, time_t timeStamp) : mRep(rep), mTimeStamp(timeStamp) {}
AuthorPending::AuthorPending(RsGixsReputation* rep, time_t timeStamp)
: mRep(rep), mTimeStamp(timeStamp) {
}
AuthorPending::~AuthorPending()
{
}
AuthorPending::~AuthorPending() {}
bool AuthorPending::expired() const
{
@ -49,7 +42,12 @@ bool AuthorPending::expired() const
bool AuthorPending::getAuthorRep(GixsReputation& rep, const RsGxsId& authorId, const RsPeerId& peerId)
{
if(mRep->haveReputation(authorId))
rep.id = authorId ;
rep.reputation_level = mRep->overallReputationLevel(authorId);
#warning can it happen that reputations do not have the info yet?
return true ;
#ifdef TO_BE_REMOVED
{
return mRep->getReputation(authorId, rep);
}
@ -58,7 +56,7 @@ bool AuthorPending::getAuthorRep(GixsReputation& rep, const RsGxsId& authorId, c
peers.push_back(peerId);
mRep->loadReputation(authorId, peers);
return false;
#endif
}
MsgAuthEntry::MsgAuthEntry()
@ -98,7 +96,7 @@ bool MsgRespPending::accepted()
GixsReputation rep;
if(getAuthorRep(rep, entry.mAuthorId, mPeerId))
{
if(rep.score >= mCutOff)
if(rep.reputation_level >= mCutOff)
{
entry.mPassedVetting = true;
count++;
@ -133,7 +131,7 @@ bool GrpRespPending::accepted()
if(getAuthorRep(rep, entry.mAuthorId, mPeerId))
{
if(rep.score >= mCutOff)
if(rep.reputation_level >= mCutOff)
{
entry.mPassedVetting = true;
count++;
@ -153,12 +151,12 @@ bool GrpRespPending::accepted()
/** NxsTransaction definition **/
const uint8_t NxsTransaction::FLAG_STATE_STARTING = 0x0001; // when
const uint8_t NxsTransaction::FLAG_STATE_RECEIVING = 0x0002; // begin receiving items for incoming trans
const uint8_t NxsTransaction::FLAG_STATE_SENDING = 0x0004; // begin sending items for outgoing trans
const uint8_t NxsTransaction::FLAG_STATE_COMPLETED = 0x008;
const uint8_t NxsTransaction::FLAG_STATE_FAILED = 0x0010;
const uint8_t NxsTransaction::FLAG_STATE_STARTING = 0x0001; // when
const uint8_t NxsTransaction::FLAG_STATE_RECEIVING = 0x0002; // begin receiving items for incoming trans
const uint8_t NxsTransaction::FLAG_STATE_SENDING = 0x0004; // begin sending items for outgoing trans
const uint8_t NxsTransaction::FLAG_STATE_FAILED = 0x0010;
const uint8_t NxsTransaction::FLAG_STATE_WAITING_CONFIRM = 0x0020;
const uint8_t NxsTransaction::FLAG_STATE_COMPLETED = 0x0080; // originaly 0x008, but probably a typo, but we cannot change it since it would break backward compatibility.
NxsTransaction::NxsTransaction()

View File

@ -171,7 +171,7 @@ bool RsGxsIntegrityCheck::check()
GXSUTIL_DEBUG() << "TimeStamping group authors' key ID " << grp->metaData->mAuthorId << " in group ID " << grp->grpId << std::endl;
#endif
if(rsIdentity!=NULL && rsIdentity->overallReputationLevel(grp->metaData->mAuthorId) > RsReputations::REPUTATION_LOCALLY_NEGATIVE)
if(rsReputations!=NULL && rsReputations->overallReputationLevel(grp->metaData->mAuthorId) > RsReputations::REPUTATION_LOCALLY_NEGATIVE)
used_gxs_ids.insert(std::make_pair(grp->metaData->mAuthorId,RsIdentityUsage(mGenExchangeClient->serviceType(),RsIdentityUsage::GROUP_AUTHOR_KEEP_ALIVE,grp->grpId))) ;
}
}
@ -269,7 +269,7 @@ bool RsGxsIntegrityCheck::check()
#ifdef DEBUG_GXSUTIL
GXSUTIL_DEBUG() << "TimeStamping message authors' key ID " << msg->metaData->mAuthorId << " in message " << msg->msgId << ", group ID " << msg->grpId<< std::endl;
#endif
if(rsIdentity!=NULL && rsIdentity->overallReputationLevel(msg->metaData->mAuthorId) > RsReputations::REPUTATION_LOCALLY_NEGATIVE)
if(rsReputations!=NULL && rsReputations->overallReputationLevel(msg->metaData->mAuthorId) > RsReputations::REPUTATION_LOCALLY_NEGATIVE)
used_gxs_ids.insert(std::make_pair(msg->metaData->mAuthorId,RsIdentityUsage(mGenExchangeClient->serviceType(),RsIdentityUsage::MESSAGE_AUTHOR_KEEP_ALIVE,msg->metaData->mGroupId,msg->metaData->mMsgId))) ;
}

View File

@ -1345,8 +1345,8 @@ int RsServer::StartupRetroShare()
// create GXS ID service
RsGxsNetService* gxsid_ns = new RsGxsNetService(
RS_SERVICE_GXS_TYPE_GXSID, gxsid_ds, nxsMgr,
mGxsIdService, mGxsIdService->getServiceInfo(),
mGxsIdService, mGxsCircles,mGxsIdService,
mGxsIdService, mGxsIdService->getServiceInfo(),
mReputations, mGxsCircles,mGxsIdService,
pgpAuxUtils,
false,false); // don't synchronise group automatic (need explicit group request)
// don't sync messages at all.
@ -1365,7 +1365,7 @@ int RsServer::StartupRetroShare()
RsGxsNetService* gxscircles_ns = new RsGxsNetService(
RS_SERVICE_GXS_TYPE_GXSCIRCLE, gxscircles_ds, nxsMgr,
mGxsCircles, mGxsCircles->getServiceInfo(),
mGxsIdService, mGxsCircles,mGxsIdService,
mReputations, mGxsCircles,mGxsIdService,
pgpAuxUtils,
true, // synchronise group automatic
true); // sync messages automatic, since they contain subscription requests.
@ -1384,7 +1384,7 @@ int RsServer::StartupRetroShare()
RsGxsNetService* posted_ns = new RsGxsNetService(
RS_SERVICE_GXS_TYPE_POSTED, posted_ds, nxsMgr,
mPosted, mPosted->getServiceInfo(),
mGxsIdService, mGxsCircles,mGxsIdService,
mReputations, mGxsCircles,mGxsIdService,
pgpAuxUtils);
mPosted->setNetworkExchangeService(posted_ns) ;
@ -1420,7 +1420,7 @@ int RsServer::StartupRetroShare()
RsGxsNetService* gxsforums_ns = new RsGxsNetService(
RS_SERVICE_GXS_TYPE_FORUMS, gxsforums_ds, nxsMgr,
mGxsForums, mGxsForums->getServiceInfo(),
mGxsIdService, mGxsCircles,mGxsIdService,
mReputations, mGxsCircles,mGxsIdService,
pgpAuxUtils);
mGxsForums->setNetworkExchangeService(gxsforums_ns) ;
@ -1436,7 +1436,7 @@ int RsServer::StartupRetroShare()
RsGxsNetService* gxschannels_ns = new RsGxsNetService(
RS_SERVICE_GXS_TYPE_CHANNELS, gxschannels_ds, nxsMgr,
mGxsChannels, mGxsChannels->getServiceInfo(),
mGxsIdService, mGxsCircles,mGxsIdService,
mReputations, mGxsCircles,mGxsIdService,
pgpAuxUtils);
mGxsChannels->setNetworkExchangeService(gxschannels_ns) ;

View File

@ -435,10 +435,10 @@ void p3GxsReputation::cleanup()
for(std::map<RsGxsId,Reputation>::iterator it(mReputations.begin());it!=mReputations.end();++it)
{
bool is_a_contact = rsIdentity->isARegularContact(*it) ;
bool is_a_contact = rsIdentity->isARegularContact(it->first) ;
if(mAutoSetPositiveOptionToContacts && is_a_contact && it->second.mOwnOpinion == RsReputations::OPINION_NEUTRAL)
should_set_to_positive.push_back(*rit) ;
should_set_to_positive.push_back(it->first) ;
}
}

View File

@ -40,6 +40,7 @@ static const uint32_t REPUTATION_IDENTITY_FLAG_PGP_KNOWN = 0x0002;
#include "retroshare/rsidentity.h"
#include "retroshare/rsreputations.h"
#include "gxs/rsgixs.h"
#include "services/p3service.h"
@ -100,7 +101,7 @@ public:
*
*/
class p3GxsReputation: public p3Service, public p3Config, public RsReputations /* , public pqiMonitor */
class p3GxsReputation: public p3Service, public p3Config, public RsGixsReputation, public RsReputations /* , public pqiMonitor */
{
public:
p3GxsReputation(p3LinkMgr *lm);

View File

@ -1030,6 +1030,7 @@ bool p3IdService::decryptData(const uint8_t *encrypted_data,uint32_t encrypted_d
}
#ifdef TO_BE_REMOVED
/********************************************************************************/
/******************* RsGixsReputation ***************************************/
/********************************************************************************/
@ -1083,6 +1084,7 @@ bool p3IdService::getReputation(const RsGxsId &id, GixsReputation &rep)
}
return false;
}
#endif
#if 0
class RegistrationRequest

View File

@ -303,9 +303,11 @@ public:
/**************** RsGixsReputation Implementation ****************/
// get Reputation.
#ifdef TO_BE_REMOVED
virtual bool haveReputation(const RsGxsId &id);
virtual bool loadReputation(const RsGxsId &id, const std::list<RsPeerId>& peers);
virtual bool getReputation(const RsGxsId &id, GixsReputation &rep);
#endif
protected:

View File

@ -110,14 +110,14 @@ void GxsIdRSTreeWidgetItem::setId(const RsGxsId &id, int column, bool retryWhenF
void GxsIdRSTreeWidgetItem::updateBannedState()
{
if(mBannedState != (rsIdentity->overallReputationLevel(mId) == RsReputations::REPUTATION_LOCALLY_NEGATIVE))
if(mBannedState != (rsReputations->overallReputationLevel(mId) == RsReputations::REPUTATION_LOCALLY_NEGATIVE))
forceUpdate() ;
}
void GxsIdRSTreeWidgetItem::forceUpdate()
{
mIdFound = false;
mBannedState = (rsIdentity->overallReputationLevel(mId) == RsReputations::REPUTATION_LOCALLY_NEGATIVE);
mBannedState = (rsReputations->overallReputationLevel(mId) == RsReputations::REPUTATION_LOCALLY_NEGATIVE);
startProcess();
}
@ -163,7 +163,7 @@ QVariant GxsIdRSTreeWidgetItem::data(int column, int role) const
if(mId.isNull())
return RSTreeWidgetItem::data(column, role);
else if(rsIdentity->overallReputationLevel(mId) == RsReputations::REPUTATION_LOCALLY_NEGATIVE)
else if(rsReputations->overallReputationLevel(mId) == RsReputations::REPUTATION_LOCALLY_NEGATIVE)
pix = QImage(BANNED_IMAGE) ;
else if (mAvatar.mSize == 0 || !pix.loadFromData(mAvatar.mData, mAvatar.mSize, "PNG"))
pix = GxsIdDetails::makeDefaultIcon(mId);

View File

@ -1546,7 +1546,7 @@ void GxsForumThreadWidget::insertMessageData(const RsGxsForumMsg &msg)
return;
}
uint32_t overall_reputation = rsIdentity->overallReputationLevel(msg.mMeta.mAuthorId) ;
uint32_t overall_reputation = rsReputations->overallReputationLevel(msg.mMeta.mAuthorId) ;
bool redacted = (overall_reputation == RsReputations::REPUTATION_LOCALLY_NEGATIVE) ;
mStateHelper->setActive(mTokenTypeMessageData, true);