summaryrefslogtreecommitdiff
path: root/src/network.cpp
diff options
context:
space:
mode:
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));