mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
fixed tree bugs in GXS sync:(1) group pulish TS is now accounted for in mServerGrpSyncMap, so that modification of metadata is propagated in the network; (2) mClientSyncMessageMap is stamped when the server cannot feed any new messages. (3) group info for no-auto-update services are still sent, but only groups already present but available with a new version are sent. This fixes the propagation of GXS avatars.
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7889 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
be6c17fe5f
commit
327c369d5c
@ -37,6 +37,7 @@
|
||||
/***
|
||||
* #define NXS_NET_DEBUG 1
|
||||
***/
|
||||
//#define NXS_NET_DEBUG 1
|
||||
//#define NXS_NET_DEBUG_0 1
|
||||
// #define NXS_NET_DEBUG_1 1
|
||||
|
||||
@ -236,8 +237,6 @@ void RsGxsNetService::syncWithPeers()
|
||||
|
||||
std::set<RsPeerId>::iterator sit = peers.begin();
|
||||
|
||||
if(mGrpAutoSync)
|
||||
{
|
||||
// for now just grps
|
||||
for(; sit != peers.end(); ++sit)
|
||||
{
|
||||
@ -263,7 +262,6 @@ void RsGxsNetService::syncWithPeers()
|
||||
#endif
|
||||
sendItem(grp);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef GXS_DISABLE_SYNC_MSGS
|
||||
|
||||
@ -1173,9 +1171,7 @@ void RsGxsNetService::updateServerSyncTS()
|
||||
|
||||
// as a grp list server also note this is the latest item you have
|
||||
if(mGrpServerUpdateItem == NULL)
|
||||
{
|
||||
mGrpServerUpdateItem = new RsGxsServerGrpUpdateItem(mServType);
|
||||
}
|
||||
|
||||
bool change = false;
|
||||
|
||||
@ -1186,6 +1182,14 @@ void RsGxsNetService::updateServerSyncTS()
|
||||
ServerMsgMap::iterator mapIT = mServerMsgUpdateMap.find(grpId);
|
||||
RsGxsServerMsgUpdateItem* msui = NULL;
|
||||
|
||||
// That accounts for modification of the meta data.
|
||||
|
||||
if(mGrpServerUpdateItem->grpUpdateTS < grpMeta->mPublishTs)
|
||||
{
|
||||
std::cerr << "publish time stamp of group " << grpId << " has changed to " << time(NULL)-grpMeta->mPublishTs << " secs ago. updating!" << std::endl;
|
||||
mGrpServerUpdateItem->grpUpdateTS = grpMeta->mPublishTs;
|
||||
}
|
||||
|
||||
if(mapIT == mServerMsgUpdateMap.end())
|
||||
{
|
||||
msui = new RsGxsServerMsgUpdateItem(mServType);
|
||||
@ -1805,7 +1809,7 @@ void RsGxsNetService::locked_pushMsgTransactionFromList(std::list<RsNxsItem*>& r
|
||||
void RsGxsNetService::locked_genReqMsgTransaction(NxsTransaction* tr)
|
||||
{
|
||||
|
||||
#ifdef NXS_NET_DEBUG_0
|
||||
#ifdef NXS_NET_DEBUG
|
||||
std::cerr << "RsGxsNetService::genReqMsgTransaction()" << std::endl;
|
||||
#endif
|
||||
|
||||
@ -1831,7 +1835,7 @@ void RsGxsNetService::locked_genReqMsgTransaction(NxsTransaction* tr)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#ifdef NXS_NET_DEBUG_0
|
||||
#ifdef NXS_NET_DEBUG
|
||||
std::cerr << " found " << msgItemL.size()<< " messages in this transaction." << std::endl;
|
||||
#endif
|
||||
|
||||
@ -1866,15 +1870,7 @@ void RsGxsNetService::locked_genReqMsgTransaction(NxsTransaction* tr)
|
||||
// peer again, unless the peer has new info about it.
|
||||
// That needs of course to reset that time to 0 when we subscribe.
|
||||
|
||||
RsGxsMsgUpdateItem *& pitem(mClientMsgUpdateMap[pid]) ;
|
||||
|
||||
if(pitem == NULL)
|
||||
{
|
||||
pitem = new RsGxsMsgUpdateItem(mServType) ;
|
||||
pitem->peerId = pid ;
|
||||
}
|
||||
|
||||
pitem->msgUpdateTS[grpId] = time(NULL) ;
|
||||
locked_stampPeerGroupUpdateTime(pid,grpId,time(NULL)) ;
|
||||
return ;
|
||||
}
|
||||
|
||||
@ -2046,6 +2042,27 @@ void RsGxsNetService::locked_genReqMsgTransaction(NxsTransaction* tr)
|
||||
mPartialMsgUpdates[tr->mTransaction->PeerId()].erase(item->grpId) ;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// The list to req is empty. That means we already have all messages that this peer can
|
||||
// provide. So we can stamp the group from this peer to be up to date.
|
||||
|
||||
locked_stampPeerGroupUpdateTime(pid,grpId,time(NULL)) ;
|
||||
}
|
||||
}
|
||||
|
||||
void RsGxsNetService::locked_stampPeerGroupUpdateTime(const RsPeerId& pid,const RsGxsGroupId& grpId,time_t tm)
|
||||
{
|
||||
RsGxsMsgUpdateItem *& pitem(mClientMsgUpdateMap[pid]) ;
|
||||
|
||||
if(pitem == NULL)
|
||||
{
|
||||
pitem = new RsGxsMsgUpdateItem(mServType) ;
|
||||
pitem->peerId = pid ;
|
||||
}
|
||||
|
||||
pitem->msgUpdateTS[grpId] = time(NULL) ;
|
||||
return ;
|
||||
}
|
||||
|
||||
void RsGxsNetService::locked_pushGrpTransactionFromList(
|
||||
@ -2093,7 +2110,6 @@ void RsGxsNetService::addGroupItemToList(NxsTransaction*& tr,
|
||||
|
||||
void RsGxsNetService::locked_genReqGrpTransaction(NxsTransaction* tr)
|
||||
{
|
||||
|
||||
// to create a transaction you need to know who you are transacting with
|
||||
// then what grps to request
|
||||
// then add an active Transaction for request
|
||||
@ -2147,7 +2163,7 @@ void RsGxsNetService::locked_genReqGrpTransaction(NxsTransaction* tr)
|
||||
latestVersion = grpSyncItem->publishTs > metaIter->second->mPublishTs;
|
||||
}
|
||||
|
||||
if(!haveItem || latestVersion)
|
||||
if( (mGrpAutoSync && !haveItem) || latestVersion)
|
||||
{
|
||||
// determine if you need to check reputation
|
||||
bool checkRep = !grpSyncItem->authorId.isNull();
|
||||
|
@ -428,6 +428,13 @@ private:
|
||||
* @param partFragments the partitioned fragments (into message ids)
|
||||
*/
|
||||
void collateGrpFragments(GrpFragments fragments, std::map<RsGxsGroupId, GrpFragments>& partFragments) const;
|
||||
|
||||
/*!
|
||||
* stamp the group info from that particular peer at the given time.
|
||||
*/
|
||||
|
||||
void locked_stampPeerGroupUpdateTime(const RsPeerId& pid,const RsGxsGroupId& grpId,time_t tm) ;
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user