From 09a6321aeb7393cdb4b5af62d2e4106d83124fdf Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 11 Jul 2012 17:52:18 -0400 Subject: Replace hasSubstitutes() with querySubstitutablePaths() querySubstitutablePaths() takes a set of paths, so this greatly reduces daemon <-> client latency. --- src/libstore/local-store.cc | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/libstore/local-store.cc') diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc index e3d23fdfbcb7..6e4cd053c859 100644 --- a/src/libstore/local-store.cc +++ b/src/libstore/local-store.cc @@ -932,16 +932,24 @@ template T getIntLine(int fd) } -bool LocalStore::hasSubstitutes(const Path & path) +PathSet LocalStore::querySubstitutablePaths(const PathSet & paths) { + PathSet res; foreach (Paths::iterator, i, substituters) { + if (res.size() == paths.size()) break; RunningSubstituter & run(runningSubstituters[*i]); startSubstituter(*i, run); - writeLine(run.to, "have\n" + path); - if (getIntLine(run.from)) return true; + string s = "have "; + foreach (PathSet::const_iterator, i, paths) + if (res.find(*i) == res.end()) { s += *i; s += " "; } + writeLine(run.to, s); + while (true) { + Path path = readLine(run.from); + if (path == "") break; + res.insert(path); + } } - - return false; + return res; } -- cgit 1.4.1