Rename GXS pullFromPeers to pullFromPeers

According to what discussed with Cyril
This commit is contained in:
Gioacchino Mazzurco 2021-11-12 19:03:02 +01:00
parent ebbd8cf938
commit cd5dad6a75
No known key found for this signature in database
GPG Key ID: A1FBCA3872E87051
4 changed files with 24 additions and 19 deletions

View File

@ -35,7 +35,7 @@
// |
// +----------- sharePublishKeys()
// |
// +----------- pullFromPeers()
// +----------- checkUpdatesFromPeers()
// | |
// | +--if AutoSync--- send global UpdateTS of each peer to itself => the peer knows the last
// | | time current peer has received an updated from himself
@ -127,14 +127,14 @@
// (Set at server side to be mGrpServerUpdateItem->grpUpdateTS)
//
// Only updated in processCompletedIncomingTransaction() from Grp list transaction.
// Used in pullFromPeers() sending in RsNxsSyncGrp once to all peers: peer will send data if
// Used in checkUpdatesFromPeers() sending in RsNxsSyncGrp once to all peers: peer will send data if
// has something new. All time comparisons are in the friends' clock time.
//
// mClientMsgUpdateMap: map< RsPeerId, map<grpId,TimeStamp > >
//
// Last msg list modification time sent by that peer Id
// Updated in processCompletedIncomingTransaction() from Grp list trans.
// Used in pullFromPeers() sending in RsNxsSyncGrp once to all peers.
// Used in checkUpdatesFromPeers() sending in RsNxsSyncGrp once to all peers.
// Set at server to be mServerMsgUpdateMap[grpId]->msgUpdateTS
//
// mGrpServerUpdateItem: TimeStamp Last group local modification timestamp over all groups
@ -150,7 +150,7 @@
//
// tick() tick()
// | |
// +---- pullFromPeers +-- recvNxsItemQueue()
// +---- checkUpdatesFromPeers() +-- recvNxsItemQueue()
// | |
// +---------------- Send global UpdateTS of each peer to itself => the peer knows +---------> +------ handleRecvSyncGroup( RsNxsSyncGrp*)
// | the last msg sent (stored in mClientGrpUpdateMap[peer_id]), | | - parse all subscribed groups. For each, send a RsNxsSyncGrpItem with publish TS
@ -457,7 +457,7 @@ int RsGxsNetService::tick()
if((elapsed) < now)
{
pullFromPeers();
checkUpdatesFromPeers();
syncGrpStatistics();
checkDistantSyncState();
@ -570,7 +570,8 @@ RsGxsGroupId RsGxsNetService::hashGrpId(const RsGxsGroupId& gid,const RsPeerId&
return RsGxsGroupId( RsDirUtil::sha1sum(tmpmem,SIZE).toByteArray() );
}
void RsGxsNetService::pullFromPeers(std::set<RsPeerId> peers)
std::error_condition RsGxsNetService::checkUpdatesFromPeers(
std::set<RsPeerId> peers )
{
#ifdef NXS_NET_DEBUG_0
RS_DBG("this=", (void*)this, ". serviceInfo=", mServiceInfo);
@ -594,8 +595,8 @@ void RsGxsNetService::pullFromPeers(std::set<RsPeerId> peers)
}
}
// Still empty? Then nothing to do
if (peers.empty()) return;
// Still empty? Reports there are no available peers
if (peers.empty()) return std::errc::network_down;
RS_STACK_MUTEX(mNxsMutex);
@ -624,7 +625,7 @@ void RsGxsNetService::pullFromPeers(std::set<RsPeerId> peers)
generic_sendItem(grp);
}
if(!mAllowMsgSync) return;
if(!mAllowMsgSync) return std::error_condition();
#ifndef GXS_DISABLE_SYNC_MSGS
@ -742,7 +743,9 @@ void RsGxsNetService::pullFromPeers(std::set<RsPeerId> peers)
}
}
#endif
#endif // ndef GXS_DISABLE_SYNC_MSGS
return std::error_condition();
}
void RsGxsNetService::generic_sendItem(rs_owner_ptr<RsItem> si)
@ -5123,7 +5126,7 @@ std::error_condition RsGxsNetService::requestPull(std::set<RsPeerId> peers)
void RsGxsNetService::handlePullRequest(
std::unique_ptr<RsNxsPullRequestItem> item )
{
pullFromPeers(std::set<RsPeerId>{item->PeerId()});
checkUpdatesFromPeers(std::set<RsPeerId>{item->PeerId()});
}
bool RsGxsNetService::getGroupServerUpdateTS(const RsGxsGroupId& gid,rstime_t& group_server_update_TS, rstime_t& msg_server_update_TS)

View File

@ -252,7 +252,8 @@ public:
/// @see RsNetworkExchangeService
void pullFromPeers(std::set<RsPeerId> peers = std::set<RsPeerId>()) override;
std::error_condition checkUpdatesFromPeers(
std::set<RsPeerId> peers = std::set<RsPeerId>() ) override;
/// @see RsNetworkExchangeService
std::error_condition requestPull(

View File

@ -327,10 +327,10 @@ public:
}
/**
* @brief Pull new stuff from peers
* @param peers peers to pull from, if empty all available peers are pulled
* @brief Check if new stuff is available from peers
* @param peers peers to check, if empty all available peers are checked
*/
virtual void pullFromPeers(
virtual std::error_condition checkUpdatesFromPeers(
std::set<RsPeerId> peers = std::set<RsPeerId>() ) = 0;
/**

View File

@ -907,12 +907,12 @@ bool p3GxsForums::subscribeToForum(const RsGxsGroupId& groupId, bool subscribe )
acknowledgeGrp(token, grp);
/* Since subscribe has been requested, the caller is most probably
* interested in getting the group messages ASAP so pull from peers without
* waiting GXS sync timer.
* interested in getting the group messages ASAP so check updates from peers
* without waiting GXS sync timer.
* Do it here as this is meaningful or not depending on the service.
* Do it only after the token has been completed otherwise the pull have no
* effect. */
if(subscribe) RsGenExchange::netService()->pullFromPeers();
if(subscribe) RsGenExchange::netService()->checkUpdatesFromPeers();
return true;
}
@ -1161,7 +1161,8 @@ std::error_condition p3GxsForums::setPostKeepForever(
std::error_condition p3GxsForums::requestSynchronization()
{
RsGenExchange::netService()->pullFromPeers();
auto errc = RsGenExchange::netService()->checkUpdatesFromPeers();
if(errc) return errc;
return RsGenExchange::netService()->requestPull();
}