aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/path-info.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstore/path-info.cc')
-rw-r--r--src/libstore/path-info.cc77
1 files changed, 21 insertions, 56 deletions
diff --git a/src/libstore/path-info.cc b/src/libstore/path-info.cc
index a9231ce8d..336a9fcfc 100644
--- a/src/libstore/path-info.cc
+++ b/src/libstore/path-info.cc
@@ -1,10 +1,27 @@
#include "path-info.hh"
-#include "worker-protocol.hh"
-#include "worker-protocol-impl.hh"
#include "store-api.hh"
namespace nix {
+GENERATE_CMP_EXT(
+ ,
+ UnkeyedValidPathInfo,
+ me->deriver,
+ me->narHash,
+ me->references,
+ me->registrationTime,
+ me->narSize,
+ //me->id,
+ me->ultimate,
+ me->sigs,
+ me->ca);
+
+GENERATE_CMP_EXT(
+ ,
+ ValidPathInfo,
+ me->path,
+ static_cast<const UnkeyedValidPathInfo &>(*me));
+
std::string ValidPathInfo::fingerprint(const Store & store) const
{
if (narSize == 0)
@@ -99,14 +116,13 @@ Strings ValidPathInfo::shortRefs() const
return refs;
}
-
ValidPathInfo::ValidPathInfo(
const Store & store,
std::string_view name,
ContentAddressWithReferences && ca,
Hash narHash)
- : path(store.makeFixedOutputPathFromCA(name, ca))
- , narHash(narHash)
+ : UnkeyedValidPathInfo(narHash)
+ , path(store.makeFixedOutputPathFromCA(name, ca))
{
std::visit(overloaded {
[this](TextInfo && ti) {
@@ -128,55 +144,4 @@ ValidPathInfo::ValidPathInfo(
}, std::move(ca).raw);
}
-
-ValidPathInfo ValidPathInfo::read(Source & source, const Store & store, unsigned int format)
-{
- return read(source, store, format, store.parseStorePath(readString(source)));
-}
-
-ValidPathInfo ValidPathInfo::read(Source & source, const Store & store, unsigned int format, StorePath && path)
-{
- auto deriver = readString(source);
- auto narHash = Hash::parseAny(readString(source), htSHA256);
- ValidPathInfo info(path, narHash);
- if (deriver != "") info.deriver = store.parseStorePath(deriver);
- info.references = WorkerProto::Serialise<StorePathSet>::read(store,
- WorkerProto::ReadConn {
- .from = source,
- .version = format,
- });
- source >> info.registrationTime >> info.narSize;
- if (format >= 16) {
- source >> info.ultimate;
- info.sigs = readStrings<StringSet>(source);
- info.ca = ContentAddress::parseOpt(readString(source));
- }
- return info;
-}
-
-
-void ValidPathInfo::write(
- Sink & sink,
- const Store & store,
- unsigned int format,
- bool includePath) const
-{
- if (includePath)
- sink << store.printStorePath(path);
- sink << (deriver ? store.printStorePath(*deriver) : "")
- << narHash.to_string(Base16, false);
- WorkerProto::write(store,
- WorkerProto::WriteConn {
- .to = sink,
- .version = format,
- },
- references);
- sink << registrationTime << narSize;
- if (format >= 16) {
- sink << ultimate
- << sigs
- << renderContentAddress(ca);
- }
-}
-
}