From 6c66331d5c34d97092a9b5e2832fed73e0da3c87 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Wed, 5 Aug 2020 20:37:48 +0000 Subject: [PATCH] WIP: Put the worker protocol `read` and `write` in a namespace to disambig --- src/libstore/remote-store.cc | 6 +++++- src/libstore/worker-protocol.hh | 15 +++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc index 2c0857466..96e0aabba 100644 --- a/src/libstore/remote-store.cc +++ b/src/libstore/remote-store.cc @@ -58,6 +58,8 @@ void writeStorePathCAMap(const Store & store, Sink & out, const StorePathCAMap & } +namespace worker_proto { + StorePath read(const Store & store, Source & from, Phantom _) { return store.parseStorePath(readString(from)); @@ -68,6 +70,8 @@ void write(const Store & store, Sink & out, const StorePath & storePath) out << store.printStorePath(storePath); } +} + /* TODO: Separate these store impls into different files, give them better names */ RemoteStore::RemoteStore(const Params & params) @@ -461,7 +465,7 @@ std::map> RemoteStore::queryDerivationOutp auto conn(getConnection()); conn->to << wopQueryDerivationOutputMap << printStorePath(path); conn.processStderr(); - return read(*this, conn->from, Phantom>> {}); + return worker_proto::read(*this, conn->from, Phantom>> {}); } diff --git a/src/libstore/worker-protocol.hh b/src/libstore/worker-protocol.hh index 384b81f08..fdd700668 100644 --- a/src/libstore/worker-protocol.hh +++ b/src/libstore/worker-protocol.hh @@ -74,6 +74,10 @@ void writeStorePaths(const Store & store, Sink & out, const StorePathSet & paths template struct Phantom {}; + +namespace worker_proto { +/* FIXME maybe move more stuff inside here */ + template std::map read(const Store & store, Source & from, Phantom> _) { @@ -81,7 +85,7 @@ std::map read(const Store & store, Source & from, Phantom {})); + resMap.insert_or_assign(std::move(thisKey), nix::worker_proto::read(store, from, Phantom {})); } return resMap; } @@ -92,7 +96,7 @@ void write(const Store & store, Sink & out, const std::map & resMap) out << resMap.size(); for (auto & i : resMap) { out << i.first; - write(store, out, i.second); + nix::worker_proto::write(store, out, i.second); } } @@ -104,7 +108,7 @@ std::optional read(const Store & store, Source & from, Phantom {}); + return nix::worker_proto::read(store, from, Phantom {}); default: throw Error("got an invalid tag bit for std::optional: %#04x", tag); } @@ -115,13 +119,16 @@ void write(const Store & store, Sink & out, const std::optional & optVal) { out << (optVal ? 1 : 0); if (optVal) - write(store, out, *optVal); + nix::worker_proto::write(store, out, *optVal); } StorePath read(const Store & store, Source & from, Phantom _); void write(const Store & store, Sink & out, const StorePath & storePath); +} + + StorePathCAMap readStorePathCAMap(const Store & store, Source & from); void writeStorePathCAMap(const Store & store, Sink & out, const StorePathCAMap & paths);