diff options
author | dec05eba <dec05eba@protonmail.com> | 2018-11-25 00:22:29 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-08-18 22:56:48 +0200 |
commit | 168fa4889c230de9016e1371e65da49a8d36e16c (patch) | |
tree | cee123ead84fdfd666af932ccedc66c68b2082d0 /src/BootstrapConnection.cpp | |
parent | 213ab157a6e696ea76feb581977ebef2e2fad217 (diff) |
Remove duplicate user add if same pubsub key, do not add user until connected
Diffstat (limited to 'src/BootstrapConnection.cpp')
-rw-r--r-- | src/BootstrapConnection.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/BootstrapConnection.cpp b/src/BootstrapConnection.cpp index d914646..f09547e 100644 --- a/src/BootstrapConnection.cpp +++ b/src/BootstrapConnection.cpp @@ -127,6 +127,15 @@ namespace sibs Log::warn("BootstrapConnection::receiveDataFromServer: No listener found for key '%s', ignoring...", pubsubKey.toString().c_str()); return; } + + for(auto existingPeer : subscribeDataIt->second.peers) + { + if(peer == existingPeer) + { + Log::debug("BootstrapConnection::receiveDataFromServer: Already connected to peer (ip: %s, port: %d)", peer->address.getAddress().c_str(), peer->address.getPort()); + return; + } + } subscribeDataIt->second.peers.push_back(peer); Log::debug("BootstrapConnection::receiveDataFromServer: Connected to peer (ip: %s, port: %d) given by bootstrap node", peer->address.getAddress().c_str(), peer->address.getPort()); } |