mirror of
https://github.com/NixOS/nix.git
synced 2025-11-16 07:22:43 +01:00
Replace hasSubstitutes() with querySubstitutablePaths()
querySubstitutablePaths() takes a set of paths, so this greatly reduces daemon <-> client latency.
This commit is contained in:
parent
58ef4d9a95
commit
09a6321aeb
8 changed files with 52 additions and 24 deletions
|
|
@ -932,16 +932,24 @@ template<class T> 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<int>(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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue