added hashstream class to hash content of RsIdentityUsage and fix duplication of identity usage statistics

This commit is contained in:
csoler 2017-01-05 23:07:59 +01:00
parent 1a2def70b5
commit d631758e8c
10 changed files with 152 additions and 112 deletions

View file

@ -172,8 +172,7 @@ class GixsReputation
int score;
};
class RsGixsReputation
class RsGixsReputation
{
public:
// get Reputation.
@ -182,7 +181,6 @@ public:
virtual bool getReputation(const RsGxsId &id, GixsReputation &rep) = 0;
};
/*** This Class pulls all the GXS Interfaces together ****/
class RsGxsIdExchange:

View file

@ -2779,8 +2779,6 @@ void RsGxsNetService::locked_genReqMsgTransaction(NxsTransaction* tr)
const RsPeerId peerFrom = tr->mTransaction->PeerId();
MsgAuthorV toVet;
std::list<RsPeerId> peers;
peers.push_back(tr->mTransaction->PeerId());
bool reqListSizeExceeded = false ;
@ -2845,22 +2843,6 @@ void RsGxsNetService::locked_genReqMsgTransaction(NxsTransaction* tr)
continue ;
}
#ifdef TO_BE_REMOVED
if(mReputations->haveReputation(syncItem->authorId) || noAuthor)
{
GixsReputation rep;
#ifdef NXS_NET_DEBUG_1
GXSNETDEBUG_PG(item->PeerId(),grpId) << ", author Id=" << syncItem->authorId << ". Reputation: " ;
#endif
if(!noAuthor)
mReputations->getReputation(syncItem->authorId, rep);
// if author is required for this message, it will simply get dropped
// at genexchange side of things
if(rep.score >= (int)grpMeta->mReputationCutOff || noAuthor)
{
#endif
#ifdef NXS_NET_DEBUG_1
GXSNETDEBUG_PG(item->PeerId(),grpId) << ", passed! Adding message to req list." << std::endl;
#endif
@ -2872,28 +2854,6 @@ void RsGxsNetService::locked_genReqMsgTransaction(NxsTransaction* tr)
msgItem->PeerId(peerFrom);
reqList.push_back(msgItem);
++reqListSize ;
#ifdef TO_BE_REMOVED
}
#ifdef NXS_NET_DEBUG_1
else
GXSNETDEBUG_PG(item->PeerId(),grpId) << ", failed!" << std::endl;
#endif
}
else
{
#ifdef NXS_NET_DEBUG_1
GXSNETDEBUG_PG(item->PeerId(),grpId) << ", no author/no reputation. Pushed to Vetting list." << std::endl;
#endif
// preload for speed
mReputations->loadReputation(syncItem->authorId, peers);
MsgAuthEntry entry;
entry.mAuthorId = syncItem->authorId;
entry.mGrpId = syncItem->grpId;
entry.mMsgId = syncItem->msgId;
toVet.push_back(entry);
}
#endif
}
#ifdef NXS_NET_DEBUG_1
else
@ -2901,15 +2861,6 @@ void RsGxsNetService::locked_genReqMsgTransaction(NxsTransaction* tr)
#endif
}
if(!toVet.empty())
{
#ifdef NXS_NET_DEBUG_1
GXSNETDEBUG_PG(item->PeerId(),grpId) << " Vetting list: " << toVet.size() << " elements." << std::endl;
#endif
MsgRespPending* mrp = new MsgRespPending(mReputations, tr->mTransaction->PeerId(), toVet, cutoff);
mPendingResp.push_back(mrp);
}
if(!reqList.empty())
{
#ifdef NXS_NET_DEBUG_1
@ -3046,7 +2997,6 @@ void RsGxsNetService::locked_genReqGrpTransaction(NxsTransaction* tr)
uint32_t transN = locked_getTransactionId();
GrpAuthorV toVet;
std::list<RsPeerId> peers;
peers.push_back(tr->mTransaction->PeerId());
@ -3076,56 +3026,9 @@ void RsGxsNetService::locked_genReqGrpTransaction(NxsTransaction* tr)
}
if( (mGrpAutoSync && !haveItem) || latestVersion)
{
// determine if you need to check reputation
bool checkRep = !grpSyncItem->authorId.isNull();
// check if you have reputation, if you don't then
// place in holding pen
if(checkRep)
{
if(mReputations->haveReputation(grpSyncItem->authorId))
{
GixsReputation rep;
mReputations->getReputation(grpSyncItem->authorId, rep);
if(rep.score >= (int)GIXS_CUT_OFF)
{
addGroupItemToList(tr, grpId, transN, reqList);
#ifdef NXS_NET_DEBUG_0
GXSNETDEBUG_PG(tr->mTransaction->PeerId(),grpId)<< " reputation cut off: limit=" << GIXS_CUT_OFF << " value=" << rep.score << ": allowed." << std::endl;
#endif
}
#ifdef NXS_NET_DEBUG_0
else
GXSNETDEBUG_PG(tr->mTransaction->PeerId(),grpId)<< " reputation cut off: limit=" << GIXS_CUT_OFF << " value=" << rep.score << ": you shall not pass." << std::endl;
#endif
}
else
{
// preload reputation for later
mReputations->loadReputation(grpSyncItem->authorId, peers);
GrpAuthEntry entry;
entry.mAuthorId = grpSyncItem->authorId;
entry.mGrpId = grpSyncItem->grpId;
toVet.push_back(entry);
}
}
else
{
addGroupItemToList(tr, grpId, transN, reqList);
}
}
addGroupItemToList(tr, grpId, transN, reqList);
}
if(!toVet.empty())
{
RsPeerId peerId = tr->mTransaction->PeerId();
GrpRespPending* grp = new GrpRespPending(mReputations, peerId, toVet);
mPendingResp.push_back(grp);
}
if(!reqList.empty())
locked_pushGrpTransactionFromList(reqList, tr->mTransaction->PeerId(), transN);
else

View file

@ -47,8 +47,7 @@ bool AuthorPending::expired() const
return time(NULL) > (mTimeStamp + EXPIRY_PERIOD_OFFSET);
}
bool AuthorPending::getAuthorRep(GixsReputation& rep,
const RsGxsId& authorId, const RsPeerId& peerId)
bool AuthorPending::getAuthorRep(GixsReputation& rep, const RsGxsId& authorId, const RsPeerId& peerId)
{
if(mRep->haveReputation(authorId))
{