mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-18 05:44:14 -05:00
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:
parent
db30ea3ad4
commit
3460457771
@ -1503,7 +1503,7 @@ void RsGxsNetService::locked_genReqMsgTransaction(NxsTransaction* tr)
|
|||||||
GixsReputation rep;
|
GixsReputation rep;
|
||||||
mReputations->getReputation(syncItem->authorId, 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);
|
RsNxsSyncMsgItem* msgItem = new RsNxsSyncMsgItem(mServType);
|
||||||
msgItem->grpId = grpId;
|
msgItem->grpId = grpId;
|
||||||
@ -2014,21 +2014,31 @@ void RsGxsNetService::locked_pushGrpRespFromList(std::list<RsNxsItem*>& respList
|
|||||||
locked_addTransaction(tr);
|
locked_addTransaction(tr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RsGxsNetService::locked_CanReceiveUpdate(const RsNxsSyncGrp *item)
|
||||||
|
{
|
||||||
|
// 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)
|
void RsGxsNetService::handleRecvSyncGroup(RsNxsSyncGrp* item)
|
||||||
{
|
{
|
||||||
|
|
||||||
RsStackMutex stack(mNxsMutex);
|
RsStackMutex stack(mNxsMutex);
|
||||||
|
|
||||||
|
if(!locked_CanReceiveUpdate(item))
|
||||||
|
return;
|
||||||
|
|
||||||
std::string peer = item->PeerId();
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::map<std::string, RsGxsGrpMetaData*> grp;
|
std::map<std::string, RsGxsGrpMetaData*> grp;
|
||||||
mDataStore->retrieveGxsGrpMetaData(grp);
|
mDataStore->retrieveGxsGrpMetaData(grp);
|
||||||
@ -2083,6 +2093,8 @@ void RsGxsNetService::handleRecvSyncGroup(RsNxsSyncGrp* item)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool RsGxsNetService::canSendGrpId(const std::string& sslId, RsGxsGrpMetaData& grpMeta, std::vector<GrpIdCircleVet>& toVet)
|
bool RsGxsNetService::canSendGrpId(const std::string& sslId, RsGxsGrpMetaData& grpMeta, std::vector<GrpIdCircleVet>& toVet)
|
||||||
{
|
{
|
||||||
// first do the simple checks
|
// first do the simple checks
|
||||||
@ -2138,22 +2150,28 @@ bool RsGxsNetService::canSendGrpId(const std::string& sslId, RsGxsGrpMetaData& g
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RsGxsNetService::locked_CanReceiveUpdate(const RsNxsSyncMsg *item)
|
||||||
|
{
|
||||||
|
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 false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
void RsGxsNetService::handleRecvSyncMessage(RsNxsSyncMsg* item)
|
void RsGxsNetService::handleRecvSyncMessage(RsNxsSyncMsg* item)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mNxsMutex);
|
RsStackMutex stack(mNxsMutex);
|
||||||
|
|
||||||
|
if(!locked_CanReceiveUpdate(item))
|
||||||
|
return;
|
||||||
|
|
||||||
const std::string& peer = item->PeerId();
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
GxsMsgMetaResult metaResult;
|
GxsMsgMetaResult metaResult;
|
||||||
GxsMsgReq req;
|
GxsMsgReq req;
|
||||||
|
|
||||||
|
@ -329,6 +329,9 @@ private:
|
|||||||
|
|
||||||
void updateServerSyncTS();
|
void updateServerSyncTS();
|
||||||
|
|
||||||
|
bool locked_CanReceiveUpdate(const RsNxsSyncGrp* item);
|
||||||
|
bool locked_CanReceiveUpdate(const RsNxsSyncMsg* item);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
typedef std::vector<RsNxsGrp*> GrpFragments;
|
typedef std::vector<RsNxsGrp*> GrpFragments;
|
||||||
|
@ -505,6 +505,7 @@ bool RsNxsSerialiser::serialiseNxsSyncMsg(RsNxsSyncMsg *item, void *data, uint32
|
|||||||
ok &= setRawUInt32(data, *size, &offset, item->createdSince);
|
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_HASH_SHA1, item->syncHash);
|
||||||
ok &= SetTlvString(data, *size, &offset, TLV_TYPE_STR_GROUPID, item->grpId);
|
ok &= SetTlvString(data, *size, &offset, TLV_TYPE_STR_GROUPID, item->grpId);
|
||||||
|
ok &= setRawUInt32(data, *size, &offset, item->updateTS);
|
||||||
|
|
||||||
if(offset != tlvsize){
|
if(offset != tlvsize){
|
||||||
#ifdef RSSERIAL_DEBUG
|
#ifdef RSSERIAL_DEBUG
|
||||||
|
Loading…
x
Reference in New Issue
Block a user