mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-07 05:42:19 -04:00
commit
233c38d8db
26 changed files with 706 additions and 348 deletions
|
@ -166,26 +166,24 @@ 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;
|
||||
};
|
||||
|
||||
/*** This Class pulls all the GXS Interfaces together ****/
|
||||
|
||||
class RsGxsIdExchange:
|
||||
public RsGenExchange,
|
||||
public RsGixsReputation,
|
||||
public RsGixs
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -2740,9 +2740,11 @@ void RsGxsNetService::locked_genReqMsgTransaction(NxsTransaction* tr)
|
|||
return ;
|
||||
}
|
||||
|
||||
#ifdef TO_REMOVE
|
||||
int cutoff = 0;
|
||||
if(grpMeta != NULL)
|
||||
cutoff = grpMeta->mReputationCutOff;
|
||||
#endif
|
||||
|
||||
GxsMsgReq reqIds;
|
||||
reqIds[grpId] = std::vector<RsGxsMessageId>();
|
||||
|
@ -2829,7 +2831,7 @@ void RsGxsNetService::locked_genReqMsgTransaction(NxsTransaction* tr)
|
|||
// - if author is locally banned, do not download.
|
||||
// - if author is not locally banned, download, whatever friends' opinion might be.
|
||||
|
||||
if(rsIdentity && rsIdentity->overallReputationLevel(syncItem->authorId) == RsReputations::REPUTATION_LOCALLY_NEGATIVE)
|
||||
if(mReputations->overallReputationLevel(syncItem->authorId) == RsReputations::REPUTATION_LOCALLY_NEGATIVE)
|
||||
{
|
||||
#ifdef NXS_NET_DEBUG_1
|
||||
GXSNETDEBUG_PG(item->PeerId(),grpId) << ", Identity " << syncItem->authorId << " is banned. Not requesting message!" << std::endl;
|
||||
|
@ -3019,7 +3021,7 @@ void RsGxsNetService::locked_genReqGrpTransaction(NxsTransaction* tr)
|
|||
// FIXTESTS global variable rsReputations not available in unittests!
|
||||
|
||||
#warning Update the code below to correctly send/recv dependign on reputation
|
||||
if(!grpSyncItem->authorId.isNull() && rsIdentity && rsIdentity->overallReputationLevel(grpSyncItem->authorId) == RsReputations::REPUTATION_LOCALLY_NEGATIVE)
|
||||
if(!grpSyncItem->authorId.isNull() && mReputations->overallReputationLevel(grpSyncItem->authorId) == RsReputations::REPUTATION_LOCALLY_NEGATIVE)
|
||||
{
|
||||
#ifdef NXS_NET_DEBUG_0
|
||||
GXSNETDEBUG_PG(tr->mTransaction->PeerId(),grpId) << " Identity " << grpSyncItem->authorId << " is banned. Not syncing group." << std::endl;
|
||||
|
@ -3139,6 +3141,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 +3174,7 @@ void RsGxsNetService::runVetting()
|
|||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// now lets do circle vetting
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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))) ;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue