1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-16 23:42: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:
Eelco Dolstra 2012-07-11 17:52:18 -04:00
parent 58ef4d9a95
commit 09a6321aeb
8 changed files with 52 additions and 24 deletions

View file

@ -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);
}
}