diff options
author | Aleksi Lindeman <dec05eba@protonmail.com> | 2018-11-25 00:22:29 +0100 |
---|---|---|
committer | Aleksi Lindeman <dec05eba@protonmail.com> | 2018-11-25 00:22:29 +0100 |
commit | 3f6c75b1ee660b9fceefa1a021bae59b581637b7 (patch) | |
tree | c4adab6b586d6c7f55fcfb7266d577cbf6db4ba1 /src/BootstrapConnection.cpp | |
parent | 84fc5532fd447cfb43ed26dca0240eee669b8338 (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()); } |