diff --git a/src/libstore/content-address.cc b/src/libstore/content-address.cc index a4d1c2912a2..ebd1763f522 100644 --- a/src/libstore/content-address.cc +++ b/src/libstore/content-address.cc @@ -21,7 +21,7 @@ std::string makeFileIngestionPrefix(const FileIngestionMethod m) { template struct overloaded : Ts... { using Ts::operator()...; }; template overloaded(Ts...) -> overloaded; -std::string renderLegacyContentAddress(LegacyContentAddress ca) { +std::string renderContentAddress(ContentAddress ca) { return std::visit(overloaded { [](TextHash th) { return "text:" @@ -35,7 +35,7 @@ std::string renderLegacyContentAddress(LegacyContentAddress ca) { }, ca); } -LegacyContentAddress parseLegacyContentAddress(std::string_view rawCa) { +ContentAddress parseContentAddress(std::string_view rawCa) { auto prefixSeparator = rawCa.find(':'); if (prefixSeparator != string::npos) { auto prefix = string(rawCa, 0, prefixSeparator); @@ -43,7 +43,7 @@ LegacyContentAddress parseLegacyContentAddress(std::string_view rawCa) { auto hashTypeAndHash = rawCa.substr(prefixSeparator+1, string::npos); Hash hash = Hash(string(hashTypeAndHash)); if (*hash.type != htSHA256) { - throw Error("parseLegacyContentAddress: the text hash should have type SHA256"); + throw Error("parseContentAddress: the text hash should have type SHA256"); } return TextHash { hash }; } else if (prefix == "fixed") { @@ -62,19 +62,19 @@ LegacyContentAddress parseLegacyContentAddress(std::string_view rawCa) { }; } } else { - throw Error("parseLegacyContentAddress: format not recognized; has to be text or fixed"); + throw Error("parseContentAddress: format not recognized; has to be text or fixed"); } } else { throw Error("Not a content address because it lacks an appropriate prefix"); } }; -std::optional parseLegacyContentAddressOpt(std::string_view rawCaOpt) { - return rawCaOpt == "" ? std::optional {} : parseLegacyContentAddress(rawCaOpt); +std::optional parseContentAddressOpt(std::string_view rawCaOpt) { + return rawCaOpt == "" ? std::optional {} : parseContentAddress(rawCaOpt); }; -std::string renderLegacyContentAddress(std::optional ca) { - return ca ? renderLegacyContentAddress(*ca) : ""; +std::string renderContentAddress(std::optional ca) { + return ca ? renderContentAddress(*ca) : ""; } } diff --git a/src/libstore/content-address.hh b/src/libstore/content-address.hh index 10a5fcf6657..5f18b0b9d4f 100644 --- a/src/libstore/content-address.hh +++ b/src/libstore/content-address.hh @@ -40,19 +40,19 @@ struct FixedOutputHash { typedef std::variant< TextHash, // for paths computed by makeTextPath() / addTextToStore FixedOutputHash // for path computed by makeFixedOutputPath -> LegacyContentAddress; +> ContentAddress; /* Compute the prefix to the hash algorithm which indicates how the files were ingested. */ std::string makeFileIngestionPrefix(const FileIngestionMethod m); -std::string renderLegacyContentAddress(LegacyContentAddress ca); +std::string renderContentAddress(ContentAddress ca); -std::string renderLegacyContentAddress(std::optional ca); +std::string renderContentAddress(std::optional ca); -LegacyContentAddress parseLegacyContentAddress(std::string_view rawCa); +ContentAddress parseContentAddress(std::string_view rawCa); -std::optional parseLegacyContentAddressOpt(std::string_view rawCaOpt); +std::optional parseContentAddressOpt(std::string_view rawCaOpt); /* * References set diff --git a/src/libstore/daemon.cc b/src/libstore/daemon.cc index 5ad7f6ade49..9a7524d39ba 100644 --- a/src/libstore/daemon.cc +++ b/src/libstore/daemon.cc @@ -664,7 +664,7 @@ static void performOp(TunnelLogger * logger, ref store, if (GET_PROTOCOL_MINOR(clientVersion) >= 16) { to << info->ultimate << info->sigs - << renderLegacyContentAddress(info->ca); + << renderContentAddress(info->ca); } } else { assert(GET_PROTOCOL_MINOR(clientVersion) >= 17); @@ -722,7 +722,7 @@ static void performOp(TunnelLogger * logger, ref store, info.setReferencesPossiblyToSelf(readStorePaths(*store, from)); from >> info.registrationTime >> info.narSize >> info.ultimate; info.sigs = readStrings(from); - info.ca = parseLegacyContentAddressOpt(readString(from)); + info.ca = parseContentAddressOpt(readString(from)); from >> repair >> dontCheckSigs; if (!trusted && dontCheckSigs) dontCheckSigs = false; diff --git a/src/libstore/legacy-ssh-store.cc b/src/libstore/legacy-ssh-store.cc index a607f1022bc..f01e642a035 100644 --- a/src/libstore/legacy-ssh-store.cc +++ b/src/libstore/legacy-ssh-store.cc @@ -113,7 +113,7 @@ struct LegacySSHStore : public Store if (GET_PROTOCOL_MINOR(conn->remoteVersion) >= 4) { auto s = readString(conn->from); info->narHash = s.empty() ? Hash() : Hash(s); - info->ca = parseLegacyContentAddressOpt(readString(conn->from)); + info->ca = parseContentAddressOpt(readString(conn->from)); info->sigs = readStrings(conn->from); } @@ -145,7 +145,7 @@ struct LegacySSHStore : public Store << info.narSize << info.ultimate << info.sigs - << renderLegacyContentAddress(info.ca); + << renderContentAddress(info.ca); try { copyNAR(source, conn->to); } catch (...) { diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc index 173e97bed59..a73966df306 100644 --- a/src/libstore/local-store.cc +++ b/src/libstore/local-store.cc @@ -592,7 +592,7 @@ uint64_t LocalStore::addValidPath(State & state, (info.narSize, info.narSize != 0) (info.ultimate ? 1 : 0, info.ultimate) (concatStringsSep(" ", info.sigs), !info.sigs.empty()) - (renderLegacyContentAddress(info.ca), (bool) info.ca) + (renderContentAddress(info.ca), (bool) info.ca) .exec(); uint64_t id = sqlite3_last_insert_rowid(state.db); @@ -666,7 +666,7 @@ void LocalStore::queryPathInfoUncached(const StorePath & path, if (s) info->sigs = tokenizeString(s, " "); s = (const char *) sqlite3_column_text(state->stmtQueryPathInfo, 7); - if (s) info->ca = parseLegacyContentAddressOpt(s); + if (s) info->ca = parseContentAddressOpt(s); /* Get the references. */ auto useQueryReferences(state->stmtQueryReferences.use()(info->id)); @@ -691,7 +691,7 @@ void LocalStore::updatePathInfo(State & state, const ValidPathInfo & info) (info.narHash.to_string(Base16, true)) (info.ultimate ? 1 : 0, info.ultimate) (concatStringsSep(" ", info.sigs), !info.sigs.empty()) - (renderLegacyContentAddress(info.ca), (bool) info.ca) + (renderContentAddress(info.ca), (bool) info.ca) (printStorePath(info.path)) .exec(); } diff --git a/src/libstore/nar-info-disk-cache.cc b/src/libstore/nar-info-disk-cache.cc index 51d8d4f4b35..c543f6ea297 100644 --- a/src/libstore/nar-info-disk-cache.cc +++ b/src/libstore/nar-info-disk-cache.cc @@ -203,7 +203,7 @@ class NarInfoDiskCacheImpl : public NarInfoDiskCache narInfo->deriver = StorePath(queryNAR.getStr(9)); for (auto & sig : tokenizeString(queryNAR.getStr(10), " ")) narInfo->sigs.insert(sig); - narInfo->ca = parseLegacyContentAddressOpt(queryNAR.getStr(11)); + narInfo->ca = parseContentAddressOpt(queryNAR.getStr(11)); return {oValid, narInfo}; }); @@ -237,7 +237,7 @@ class NarInfoDiskCacheImpl : public NarInfoDiskCache (concatStringsSep(" ", info->shortRefs())) (info->deriver ? std::string(info->deriver->to_string()) : "", (bool) info->deriver) (concatStringsSep(" ", info->sigs)) - (renderLegacyContentAddress(info->ca)) + (renderContentAddress(info->ca)) (time(0)).exec(); } else { diff --git a/src/libstore/nar-info.cc b/src/libstore/nar-info.cc index ecec5bad80b..0796de46648 100644 --- a/src/libstore/nar-info.cc +++ b/src/libstore/nar-info.cc @@ -70,7 +70,7 @@ NarInfo::NarInfo(const Store & store, const std::string & s, const std::string & else if (name == "CA") { if (ca) corrupt(); // FIXME: allow blank ca or require skipping field? - ca = parseLegacyContentAddressOpt(value); + ca = parseContentAddressOpt(value); } pos = eol + 1; @@ -107,7 +107,7 @@ std::string NarInfo::to_string(const Store & store) const res += "Sig: " + sig + "\n"; if (ca) - res += "CA: " + renderLegacyContentAddress(*ca) + "\n"; + res += "CA: " + renderContentAddress(*ca) + "\n"; return res; } diff --git a/src/libstore/path-info.hh b/src/libstore/path-info.hh index 5b2716b769f..fcd080933fb 100644 --- a/src/libstore/path-info.hh +++ b/src/libstore/path-info.hh @@ -51,7 +51,7 @@ struct ValidPathInfo : PathReferences and the store path would be computed from the name component, ‘narHash’ and ‘references’. However, we support many types of content addresses. */ - std::optional ca; + std::optional ca; bool operator == (const ValidPathInfo & i) const { diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc index aee82599bf0..100feeafe8d 100644 --- a/src/libstore/remote-store.cc +++ b/src/libstore/remote-store.cc @@ -45,7 +45,7 @@ std::set readStorePathDescriptorSet(const Store & store, So // TODO // auto count = readNum(from); // while (count--) - // paths.insert_or_assign(store.parseStorePath(readString(from)), parseLegacyContentAddressOpt(readString(from))); + // paths.insert_or_assign(store.parseStorePath(readString(from)), parseContentAddressOpt(readString(from))); return paths; } @@ -55,7 +55,7 @@ void writeStorePathDescriptorSet(const Store & store, Sink & out, const std::set //out << paths.size(); //for (auto & i : paths) { // out << store.printStorePath(i.first); - // out << renderLegacyContentAddress(i.second); + // out << renderContentAddress(i.second); //} } @@ -436,7 +436,7 @@ void RemoteStore::queryPathInfoUncached(const StorePath & path, if (GET_PROTOCOL_MINOR(conn->daemonVersion) >= 16) { conn->from >> info->ultimate; info->sigs = readStrings(conn->from); - info->ca = parseLegacyContentAddressOpt(readString(conn->from)); + info->ca = parseContentAddressOpt(readString(conn->from)); } } callback(std::move(info)); @@ -532,7 +532,7 @@ void RemoteStore::addToStore(const ValidPathInfo & info, Source & source, << info.narHash.to_string(Base16, false); writeStorePaths(*this, conn->to, info.referencesPossiblyToSelf()); conn->to << info.registrationTime << info.narSize - << info.ultimate << info.sigs << renderLegacyContentAddress(info.ca) + << info.ultimate << info.sigs << renderContentAddress(info.ca) << repair << !checkSigs; bool tunnel = GET_PROTOCOL_MINOR(conn->daemonVersion) >= 21; if (!tunnel) copyNAR(source, conn->to); diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc index 80d336209a6..d92537845d8 100644 --- a/src/libstore/store-api.cc +++ b/src/libstore/store-api.cc @@ -507,7 +507,7 @@ void Store::pathInfoToJSON(JSONPlaceholder & jsonOut, const StorePathSet & store } if (info->ca) - jsonPath.attr("ca", renderLegacyContentAddress(info->ca)); + jsonPath.attr("ca", renderContentAddress(info->ca)); std::pair closureSizes; diff --git a/src/nix-store/nix-store.cc b/src/nix-store/nix-store.cc index b96363e5667..04e408c73fa 100644 --- a/src/nix-store/nix-store.cc +++ b/src/nix-store/nix-store.cc @@ -870,7 +870,7 @@ static void opServe(Strings opFlags, Strings opArgs) out << info->narSize // downloadSize << info->narSize; if (GET_PROTOCOL_MINOR(clientVersion) >= 4) - out << (info->narHash ? info->narHash.to_string(Base32, true) : "") << renderLegacyContentAddress(info->ca) << info->sigs; + out << (info->narHash ? info->narHash.to_string(Base32, true) : "") << renderContentAddress(info->ca) << info->sigs; } catch (InvalidPath &) { } } @@ -958,7 +958,7 @@ static void opServe(Strings opFlags, Strings opArgs) info.setReferencesPossiblyToSelf(readStorePaths(*store, in)); in >> info.registrationTime >> info.narSize >> info.ultimate; info.sigs = readStrings(in); - info.ca = parseLegacyContentAddressOpt(readString(in)); + info.ca = parseContentAddressOpt(readString(in)); if (info.narSize == 0) throw Error("narInfo is too old and missing the narSize field"); diff --git a/src/nix/path-info.cc b/src/nix/path-info.cc index 126b69635e3..b89a44f83cc 100644 --- a/src/nix/path-info.cc +++ b/src/nix/path-info.cc @@ -115,7 +115,7 @@ struct CmdPathInfo : StorePathsCommand, MixJSON std::cout << '\t'; Strings ss; if (info->ultimate) ss.push_back("ultimate"); - if (info->ca) ss.push_back("ca:" + renderLegacyContentAddress(*info->ca)); + if (info->ca) ss.push_back("ca:" + renderContentAddress(*info->ca)); for (auto & sig : info->sigs) ss.push_back(sig); std::cout << concatStringsSep(" ", ss); }