From c27fe22efe0a71f4ffe43ce7a912d7ea0322e094 Mon Sep 17 00:00:00 2001
From: Nicolas Pope <nwpope@utu.fi>
Date: Thu, 21 Feb 2019 14:58:26 +0200
Subject: [PATCH] RPC experiment, not working

---
 p2p-rm/src/cluster.cpp | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/p2p-rm/src/cluster.cpp b/p2p-rm/src/cluster.cpp
index 91f6002d8..3647c62a7 100644
--- a/p2p-rm/src/cluster.cpp
+++ b/p2p-rm/src/cluster.cpp
@@ -77,6 +77,30 @@ Blob *Cluster::_lookup(const char *uri) {
 
 	auto b = blobs_[u.getBaseURI()];
 	std::cout << "Blob Found for " << u.getBaseURI() << " = " << (b != nullptr) << std::endl;
+
+	if (b == nullptr) {
+		// Must do a p2p search for this URI...
+		int rpcid = rpcid_++;
+
+		for (auto p : peers_) {
+			p->send(P2P_FINDOWNER, ftl::net::rpc_pack(rpcid,uri));
+		}
+
+		int limit = 10;
+		while (limit >= 0 && !rpc_results_[rpcid] == nullptr) {
+			ftl::net::wait();
+			limit--;
+		}
+
+		if (rpc_results[rpcid]) {
+			// Unpack the data
+			auto res = rpc_results[rpcid];
+			
+		} else {
+			// No results;
+		}
+	}
+
 	return b;
 }
 
-- 
GitLab