summaryrefslogtreecommitdiff
path: root/src/network.cpp
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2023-05-23 22:11:42 +0200
committerRoman Smrž <roman.smrz@seznam.cz>2023-05-23 22:32:01 +0200
commit15ad6ae7bd64d8d7319d75dbbb0827addd22fef2 (patch)
treec5f7ac828f4c1d5f51c461ad332b83e570ce3b26 /src/network.cpp
parentfce349f8f1c53d3e205a8d86b79784fdfd2b7b7a (diff)
Message sending to identity or contact
Diffstat (limited to 'src/network.cpp')
-rw-r--r--src/network.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/network.cpp b/src/network.cpp
index 1eb33d0..929908a 100644
--- a/src/network.cpp
+++ b/src/network.cpp
@@ -73,6 +73,20 @@ PeerList & Server::peerList() const
return p->plist;
}
+optional<Peer> Server::peer(const Identity & identity) const
+{
+ scoped_lock lock(p->dataMutex);
+
+ for (auto & peer : p->peers) {
+ const auto & pid = peer->identity;
+ if (holds_alternative<Identity>(pid))
+ if (std::get<Identity>(pid).finalOwner().sameAs(identity))
+ return peer->lpeer;
+ }
+
+ return nullopt;
+}
+
void Server::addPeer(const string & node) const
{
return addPeer(node, to_string(Priv::discoveryPort));