about summary refs log tree commit diff
path: root/src/libstore/remote-store.cc
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2012-07-11T21·52-0400
committerEelco Dolstra <eelco.dolstra@logicblox.com>2012-07-11T21·52-0400
commit09a6321aeb7393cdb4b5af62d2e4106d83124fdf (patch)
treedc7066fa0145a37b4a82edd7b8a64430293a3bfa /src/libstore/remote-store.cc
parent58ef4d9a95584fb89ebcf6222fbac6e698aa6b0b (diff)
Replace hasSubstitutes() with querySubstitutablePaths()
querySubstitutablePaths() takes a set of paths, so this greatly
reduces daemon <-> client latency.
Diffstat (limited to 'src/libstore/remote-store.cc')
-rw-r--r--src/libstore/remote-store.cc24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc
index 0cd29c5751d2..2232720c2bfd 100644
--- a/src/libstore/remote-store.cc
+++ b/src/libstore/remote-store.cc
@@ -219,13 +219,13 @@ bool RemoteStore::isValidPath(const Path & path)
 
 PathSet RemoteStore::queryValidPaths(const PathSet & paths)
 {
+    openConnection();
     if (GET_PROTOCOL_MINOR(daemonVersion) < 12) {
         PathSet res;
         foreach (PathSet::const_iterator, i, paths)
             if (isValidPath(*i)) res.insert(*i);
         return res;
     } else {
-        openConnection();
         writeInt(wopQueryValidPaths, to);
         writeStrings(paths, to);
         processStderr();
@@ -243,14 +243,24 @@ PathSet RemoteStore::queryAllValidPaths()
 }
 
 
-bool RemoteStore::hasSubstitutes(const Path & path)
+PathSet RemoteStore::querySubstitutablePaths(const PathSet & paths)
 {
     openConnection();
-    writeInt(wopHasSubstitutes, to);
-    writeString(path, to);
-    processStderr();
-    unsigned int reply = readInt(from);
-    return reply != 0;
+    if (GET_PROTOCOL_MINOR(daemonVersion) < 12) {
+        PathSet res;
+        foreach (PathSet::const_iterator, i, paths) {
+            writeInt(wopHasSubstitutes, to);
+            writeString(*i, to);
+            processStderr();
+            if (readInt(from)) res.insert(*i);
+        }
+        return res;
+    } else {
+        writeInt(wopQuerySubstitutablePaths, to);
+        writeStrings(paths, to);
+        processStderr();
+        return readStorePaths<PathSet>(from);
+    }
 }