mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-30 09:56:14 -05:00
Merge pull request #2593 from csoler/v0.6-FriendServer2
added list of already received peers from FS so that we do not request them again
This commit is contained in:
commit
016f38829d
@ -1 +1 @@
|
|||||||
Subproject commit 6abbec95073f3c1eb5059cbf8441111ef4a317a7
|
Subproject commit 659423769541169457c41f71c8a038e2d64ba079
|
@ -1 +1 @@
|
|||||||
Subproject commit 59ebd813697eda75b188ea5a8cc5d650c5602700
|
Subproject commit ac742c869a7187de467c38e73c0ea7b87e09ffdb
|
@ -88,7 +88,7 @@ void FriendServer::handleClientPublish(const RsFriendServerClientPublishItem *it
|
|||||||
|
|
||||||
std::map<RsPeerId,RsPgpFingerprint> friends;
|
std::map<RsPeerId,RsPgpFingerprint> friends;
|
||||||
sr_item.nonce = pi->second.last_nonce;
|
sr_item.nonce = pi->second.last_nonce;
|
||||||
sr_item.friend_invites = computeListOfFriendInvites(item->n_requested_friends,pi->first,friends);
|
sr_item.friend_invites = computeListOfFriendInvites(item->n_requested_friends,item->already_received_peers,pi->first,friends);
|
||||||
sr_item.PeerId(item->PeerId());
|
sr_item.PeerId(item->PeerId());
|
||||||
|
|
||||||
// Update the have_added_as_friend for the list of each peer. We do that before sending because sending destroys
|
// Update the have_added_as_friend for the list of each peer. We do that before sending because sending destroys
|
||||||
@ -142,7 +142,10 @@ void FriendServer::handleClientPublish(const RsFriendServerClientPublishItem *it
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<std::string, bool> FriendServer::computeListOfFriendInvites(uint32_t nb_reqs_invites, const RsPeerId &pid, std::map<RsPeerId,RsPgpFingerprint>& friends)
|
std::map<std::string, bool> FriendServer::computeListOfFriendInvites(uint32_t nb_reqs_invites,
|
||||||
|
const std::set<RsPeerId>& already_known_peers,
|
||||||
|
const RsPeerId &pid,
|
||||||
|
std::map<RsPeerId,RsPgpFingerprint>& friends)
|
||||||
{
|
{
|
||||||
// Strategy: we want to return the same set of friends for a given PGP profile key.
|
// Strategy: we want to return the same set of friends for a given PGP profile key.
|
||||||
// Still, using some closest distance strategy, the n-closest peers for profile A is not the
|
// Still, using some closest distance strategy, the n-closest peers for profile A is not the
|
||||||
@ -168,17 +171,20 @@ std::map<std::string, bool> FriendServer::computeListOfFriendInvites(uint32_t nb
|
|||||||
|
|
||||||
std::map<std::string,bool> res;
|
std::map<std::string,bool> res;
|
||||||
|
|
||||||
auto add_from = [&res,&friends,nb_reqs_invites,this](bool added,const std::map<PeerInfo::PeerDistance,RsPeerId>& lst) -> bool
|
auto add_from = [&res,&friends,nb_reqs_invites,already_known_peers,this](bool added,
|
||||||
|
const std::map<PeerInfo::PeerDistance, RsPeerId>& lst) -> bool
|
||||||
{
|
{
|
||||||
for(const auto& pid:lst)
|
for(const auto& pid:lst)
|
||||||
|
if(already_known_peers.find(pid.second) == already_known_peers.end())
|
||||||
{
|
{
|
||||||
const auto p = mCurrentClientPeers.find(pid.second);
|
const auto p = mCurrentClientPeers.find(pid.second);
|
||||||
res.insert(std::make_pair(p->second.short_certificate,added));
|
res.insert(std::make_pair(p->second.short_certificate,added));
|
||||||
friends.insert(std::make_pair(p->first,p->second.pgp_fingerprint));
|
friends.insert(std::make_pair(p->first,p->second.pgp_fingerprint));
|
||||||
|
|
||||||
if(res.size() >= nb_reqs_invites)
|
if(res.size() + already_known_peers.size() >= nb_reqs_invites)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ private:
|
|||||||
std::map<RsPeerId,PeerInfo>::iterator handleIncomingClientData(const std::string& pgp_public_key_b64,const std::string& short_invite_b64);
|
std::map<RsPeerId,PeerInfo>::iterator handleIncomingClientData(const std::string& pgp_public_key_b64,const std::string& short_invite_b64);
|
||||||
|
|
||||||
// Computes the appropriate list of short invites to send to a given peer.
|
// Computes the appropriate list of short invites to send to a given peer.
|
||||||
std::map<std::string, bool> computeListOfFriendInvites(uint32_t nb_reqs_invites, const RsPeerId &pid, std::map<RsPeerId,RsPgpFingerprint>& friends);
|
std::map<std::string, bool> computeListOfFriendInvites(uint32_t nb_reqs_invites, const std::set<RsPeerId> &already_received_peers, const RsPeerId &pid, std::map<RsPeerId,RsPgpFingerprint>& friends);
|
||||||
|
|
||||||
// Compute the distance between peers using the random bias (It's not really a distance though. I'm not sure about the triangular inequality).
|
// Compute the distance between peers using the random bias (It's not really a distance though. I'm not sure about the triangular inequality).
|
||||||
PeerInfo::PeerDistance computePeerDistance(const RsPgpFingerprint &p1, const RsPgpFingerprint &p2);
|
PeerInfo::PeerDistance computePeerDistance(const RsPgpFingerprint &p1, const RsPgpFingerprint &p2);
|
||||||
|
Loading…
Reference in New Issue
Block a user