nxs grp sync optimisation now working

- msg still needs a bit of work
- bug fix in grp sync found (reputation logic wrong)
- bug in nxssyncmsg serialisation from recent work


git-svn-id: http://svn.code.sf.net/p/retroshare/code/branches/v0.5-gxs_finale@6909 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
chrisparker126 2013-11-25 22:28:17 +00:00
parent db30ea3ad4
commit 3460457771
3 changed files with 41 additions and 19 deletions

View File

@ -1503,7 +1503,7 @@ void RsGxsNetService::locked_genReqMsgTransaction(NxsTransaction* tr)
GixsReputation rep;
mReputations->getReputation(syncItem->authorId, rep);
if(rep.score > GIXS_CUT_OFF)
if(rep.score > GIXS_CUT_OFF || syncItem->authorId.empty())
{
RsNxsSyncMsgItem* msgItem = new RsNxsSyncMsgItem(mServType);
msgItem->grpId = grpId;
@ -2014,21 +2014,31 @@ void RsGxsNetService::locked_pushGrpRespFromList(std::list<RsNxsItem*>& respList
locked_addTransaction(tr);
}
void RsGxsNetService::handleRecvSyncGroup(RsNxsSyncGrp* item)
bool RsGxsNetService::locked_CanReceiveUpdate(const RsNxsSyncGrp *item)
{
RsStackMutex stack(mNxsMutex);
std::string peer = item->PeerId();
// don't sync if you have no new updates for this peer
if(mGrpServerUpdateItem)
{
if(item->updateTS >= mGrpServerUpdateItem->grpUpdateTS && item->updateTS != 0)
{
return false;
}
}
return true;
}
void RsGxsNetService::handleRecvSyncGroup(RsNxsSyncGrp* item)
{
RsStackMutex stack(mNxsMutex);
if(!locked_CanReceiveUpdate(item))
return;
}
}
std::string peer = item->PeerId();
std::map<std::string, RsGxsGrpMetaData*> grp;
mDataStore->retrieveGxsGrpMetaData(grp);
@ -2083,6 +2093,8 @@ void RsGxsNetService::handleRecvSyncGroup(RsNxsSyncGrp* item)
return;
}
bool RsGxsNetService::canSendGrpId(const std::string& sslId, RsGxsGrpMetaData& grpMeta, std::vector<GrpIdCircleVet>& toVet)
{
// first do the simple checks
@ -2138,21 +2150,27 @@ bool RsGxsNetService::canSendGrpId(const std::string& sslId, RsGxsGrpMetaData& g
return true;
}
void RsGxsNetService::handleRecvSyncMessage(RsNxsSyncMsg* item)
bool RsGxsNetService::locked_CanReceiveUpdate(const RsNxsSyncMsg *item)
{
RsStackMutex stack(mNxsMutex);
const std::string& peer = item->PeerId();
ServerMsgMap::const_iterator cit = mServerMsgUpdateMap.find(item->grpId);
if(cit != mServerMsgUpdateMap.end())
{
const RsGxsServerMsgUpdateItem *msui = cit->second;
if(item->updateTS > msui->msgUpdateTS && item->updateTS != 0)
return;
if(item->updateTS >= msui->msgUpdateTS && item->updateTS != 0)
return false;
}
return true;
}
void RsGxsNetService::handleRecvSyncMessage(RsNxsSyncMsg* item)
{
RsStackMutex stack(mNxsMutex);
if(!locked_CanReceiveUpdate(item))
return;
const std::string& peer = item->PeerId();
GxsMsgMetaResult metaResult;
GxsMsgReq req;

View File

@ -329,6 +329,9 @@ private:
void updateServerSyncTS();
bool locked_CanReceiveUpdate(const RsNxsSyncGrp* item);
bool locked_CanReceiveUpdate(const RsNxsSyncMsg* item);
private:
typedef std::vector<RsNxsGrp*> GrpFragments;

View File

@ -505,6 +505,7 @@ bool RsNxsSerialiser::serialiseNxsSyncMsg(RsNxsSyncMsg *item, void *data, uint32
ok &= setRawUInt32(data, *size, &offset, item->createdSince);
ok &= SetTlvString(data, *size, &offset, TLV_TYPE_STR_HASH_SHA1, item->syncHash);
ok &= SetTlvString(data, *size, &offset, TLV_TYPE_STR_GROUPID, item->grpId);
ok &= setRawUInt32(data, *size, &offset, item->updateTS);
if(offset != tlvsize){
#ifdef RSSERIAL_DEBUG