Skip to content

Commit

Permalink
Rename ContentAddress to StorePathDescriptor
Browse files Browse the repository at this point in the history
  • Loading branch information
meditans committed Jul 13, 2020
1 parent 97234c1 commit ff07296
Show file tree
Hide file tree
Showing 15 changed files with 35 additions and 35 deletions.
2 changes: 1 addition & 1 deletion src/libfetchers/tarball.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ DownloadFileResult downloadFile(
auto hash = hashString(htSHA256, *res.data);
ValidPathInfo info {
*store,
ContentAddress {
StorePathDescriptor {
.name = name,
.info = FixedOutputInfo {
{
Expand Down
18 changes: 9 additions & 9 deletions src/libstore/build.cc
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ class Worker
GoalPtr makeDerivationGoal(const StorePath & drvPath, const StringSet & wantedOutputs, BuildMode buildMode = bmNormal);
std::shared_ptr<DerivationGoal> makeBasicDerivationGoal(const StorePath & drvPath,
const BasicDerivation & drv, BuildMode buildMode = bmNormal);
GoalPtr makeSubstitutionGoal(const StorePath & storePath, RepairFlag repair = NoRepair, std::optional<ContentAddress> ca = std::nullopt);
GoalPtr makeSubstitutionGoal(const StorePath & storePath, RepairFlag repair = NoRepair, std::optional<StorePathDescriptor> ca = std::nullopt);

/* Remove a dead goal. */
void removeGoal(GoalPtr goal);
Expand Down Expand Up @@ -3717,7 +3717,7 @@ void DerivationGoal::registerOutputs()
/* Check that fixed-output derivations produced the right
outputs (i.e., the content hash should match the specified
hash). */
std::optional<ContentAddress> ca;
std::optional<StorePathDescriptor> ca;

if (fixedOutput) {

Expand Down Expand Up @@ -3773,7 +3773,7 @@ void DerivationGoal::registerOutputs()
else
assert(worker.store.parseStorePath(path) == dest);

ca = ContentAddress {
ca = StorePathDescriptor {
.name = std::string { i.second.path.name() },
.info = FixedOutputInfo {
{
Expand Down Expand Up @@ -3847,7 +3847,7 @@ void DerivationGoal::registerOutputs()
}

auto info = ca
? ValidPathInfo { worker.store, ContentAddress { *ca } }
? ValidPathInfo { worker.store, StorePathDescriptor { *ca } }
: ValidPathInfo { worker.store.parseStorePath(path) };
info.narHash = hash.first;
info.narSize = hash.second;
Expand Down Expand Up @@ -4281,7 +4281,7 @@ class SubstitutionGoal : public Goal

private:
/* The store path that should be realised through a substitute. */
// TODO std::variant<StorePath, ContentAddress> storePath;
// TODO std::variant<StorePath, StorePathDescriptor> storePath;
StorePath storePath;

/* The remaining substituters. */
Expand Down Expand Up @@ -4319,10 +4319,10 @@ class SubstitutionGoal : public Goal

/* Content address for recomputing store path */
// TODO delete once `storePath` is variant.
std::optional<ContentAddress> ca;
std::optional<StorePathDescriptor> ca;

public:
SubstitutionGoal(const StorePath & storePath, Worker & worker, RepairFlag repair = NoRepair, std::optional<ContentAddress> ca = std::nullopt);
SubstitutionGoal(const StorePath & storePath, Worker & worker, RepairFlag repair = NoRepair, std::optional<StorePathDescriptor> ca = std::nullopt);
~SubstitutionGoal();

void timedOut(Error && ex) override { abort(); };
Expand Down Expand Up @@ -4352,7 +4352,7 @@ class SubstitutionGoal : public Goal
};


SubstitutionGoal::SubstitutionGoal(const StorePath & storePath, Worker & worker, RepairFlag repair, std::optional<ContentAddress> ca)
SubstitutionGoal::SubstitutionGoal(const StorePath & storePath, Worker & worker, RepairFlag repair, std::optional<StorePathDescriptor> ca)
: Goal(worker)
, storePath(storePath)
, repair(repair)
Expand Down Expand Up @@ -4699,7 +4699,7 @@ std::shared_ptr<DerivationGoal> Worker::makeBasicDerivationGoal(const StorePath
}


GoalPtr Worker::makeSubstitutionGoal(const StorePath & path, RepairFlag repair, std::optional<ContentAddress> ca)
GoalPtr Worker::makeSubstitutionGoal(const StorePath & path, RepairFlag repair, std::optional<StorePathDescriptor> ca)
{
GoalPtr goal = substitutionGoals[path].lock(); // FIXME
if (!goal) {
Expand Down
4 changes: 2 additions & 2 deletions src/libstore/content-address.hh
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,14 @@ struct FixedOutputInfo : FixedOutputHash {
PathReferences<StorePath> references;
};

struct ContentAddress {
struct StorePathDescriptor {
std::string name;
std::variant<
TextInfo,
FixedOutputInfo
> info;

bool operator < (const ContentAddress & other) const
bool operator < (const StorePathDescriptor & other) const
{
return name < other.name;
}
Expand Down
2 changes: 1 addition & 1 deletion src/libstore/daemon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
case wopQuerySubstitutablePathInfos: {
SubstitutablePathInfos infos;
auto paths = readStorePaths<StorePathSet>(*store, from);
std::set<ContentAddress> caPaths;
std::set<StorePathDescriptor> caPaths;
if (GET_PROTOCOL_MINOR(clientVersion) > 22)
caPaths = readContentAddressSet(*store, from);
logger->startWork();
Expand Down
2 changes: 1 addition & 1 deletion src/libstore/local-store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ StorePathSet LocalStore::querySubstitutablePaths(const StorePathSet & paths)
}


void LocalStore::querySubstitutablePathInfos(const StorePathSet & paths, const std::set<ContentAddress> & caPaths, SubstitutablePathInfos & infos)
void LocalStore::querySubstitutablePathInfos(const StorePathSet & paths, const std::set<StorePathDescriptor> & caPaths, SubstitutablePathInfos & infos)
{
if (!settings.useSubstitutes) return;

Expand Down
2 changes: 1 addition & 1 deletion src/libstore/local-store.hh
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public:
StorePathSet querySubstitutablePaths(const StorePathSet & paths) override;

void querySubstitutablePathInfos(const StorePathSet & paths,
const std::set<ContentAddress> & caPaths,
const std::set<StorePathDescriptor> & caPaths,
SubstitutablePathInfos & infos) override;

void addToStore(const ValidPathInfo & info, Source & source,
Expand Down
4 changes: 2 additions & 2 deletions src/libstore/misc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@ void Store::computeFSClosure(const StorePath & startPath,
}


std::optional<ContentAddress> getDerivationCA(const BasicDerivation & drv)
std::optional<StorePathDescriptor> getDerivationCA(const BasicDerivation & drv)
{
auto out = drv.outputs.find("out");
if (out != drv.outputs.end() && out->second.hash) {
return ContentAddress {
return StorePathDescriptor {
.name = std::string { out->second.path.name() },
.info = FixedOutputInfo { *out->second.hash, {} },
};
Expand Down
4 changes: 2 additions & 2 deletions src/libstore/path-info.hh
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ struct ValidPathInfo : PathReferences<StorePath>

void sign(const Store & store, const SecretKey & secretKey);

std::optional<ContentAddress> fullContentAddressOpt() const;
std::optional<StorePathDescriptor> fullContentAddressOpt() const;

/* Return true iff the path is verifiably content-addressed. */
bool isContentAddressed(const Store & store) const;
Expand Down Expand Up @@ -101,7 +101,7 @@ struct ValidPathInfo : PathReferences<StorePath>
ValidPathInfo(const StorePath & path) : path(path) { };

ValidPathInfo(const Store & store,
ContentAddress && ca);
StorePathDescriptor && ca);

virtual ~ValidPathInfo() { }
};
Expand Down
8 changes: 4 additions & 4 deletions src/libstore/remote-store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,17 @@ void writeStorePaths(const Store & store, Sink & out, const StorePathSet & paths
out << store.printStorePath(i);
}

std::set<ContentAddress> readContentAddressSet(const Store & store, Source & from)
std::set<StorePathDescriptor> readContentAddressSet(const Store & store, Source & from)
{
std::set<ContentAddress> paths;
std::set<StorePathDescriptor> paths;
// TODO
// auto count = readNum<size_t>(from);
// while (count--)
// paths.insert_or_assign(store.parseStorePath(readString(from)), parseLegacyContentAddressOpt(readString(from)));
return paths;
}

void writeContentAddressSet(const Store & store, Sink & out, const std::set<ContentAddress> & paths)
void writeContentAddressSet(const Store & store, Sink & out, const std::set<StorePathDescriptor> & paths)
{
// TODO
//out << paths.size();
Expand Down Expand Up @@ -352,7 +352,7 @@ StorePathSet RemoteStore::querySubstitutablePaths(const StorePathSet & paths)
}


void RemoteStore::querySubstitutablePathInfos(const StorePathSet & paths, const std::set<ContentAddress> & caPaths, SubstitutablePathInfos & infos)
void RemoteStore::querySubstitutablePathInfos(const StorePathSet & paths, const std::set<StorePathDescriptor> & caPaths, SubstitutablePathInfos & infos)
{
if (paths.empty() && caPaths.empty()) return;

Expand Down
2 changes: 1 addition & 1 deletion src/libstore/remote-store.hh
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public:
StorePathSet querySubstitutablePaths(const StorePathSet & paths) override;

void querySubstitutablePathInfos(const StorePathSet & paths,
const std::set<ContentAddress> & caPaths,
const std::set<StorePathDescriptor> & caPaths,
SubstitutablePathInfos & infos) override;

void addToStore(const ValidPathInfo & info, Source & nar,
Expand Down
8 changes: 4 additions & 4 deletions src/libstore/store-api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ StorePath Store::makeTextPath(std::string_view name, const TextInfo & info) cons
template<class... Ts> struct overloaded : Ts... { using Ts::operator()...; };
template<class... Ts> overloaded(Ts...) -> overloaded<Ts...>;

StorePath Store::makeFixedOutputPathFromCA(const ContentAddress & info) const
StorePath Store::makeFixedOutputPathFromCA(const StorePathDescriptor & info) const
{
// New template
return std::visit(overloaded {
Expand Down Expand Up @@ -843,12 +843,12 @@ void ValidPathInfo::sign(const Store & store, const SecretKey & secretKey)
sigs.insert(secretKey.signDetached(fingerprint(store)));
}

std::optional<ContentAddress> ValidPathInfo::fullContentAddressOpt() const
std::optional<StorePathDescriptor> ValidPathInfo::fullContentAddressOpt() const
{
if (! ca)
return std::nullopt;

return ContentAddress {
return StorePathDescriptor {
.name = std::string { path.name() },
.info = std::visit(overloaded {
[&](TextHash th) {
Expand Down Expand Up @@ -913,7 +913,7 @@ Strings ValidPathInfo::shortRefs() const

ValidPathInfo::ValidPathInfo(
const Store & store,
ContentAddress && info)
StorePathDescriptor && info)
: path(store.makeFixedOutputPathFromCA(info))
{
std::visit(overloaded {
Expand Down
6 changes: 3 additions & 3 deletions src/libstore/store-api.hh
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public:

StorePath makeTextPath(std::string_view name, const TextInfo & info) const;

StorePath makeFixedOutputPathFromCA(const ContentAddress & info) const;
StorePath makeFixedOutputPathFromCA(const StorePathDescriptor & info) const;

/* This is the preparatory part of addToStore(); it computes the
store path to which srcPath is to be copied. Returns the store
Expand Down Expand Up @@ -347,7 +347,7 @@ public:
does not have substitute info, it's omitted from the resulting
‘infos’ map. */
virtual void querySubstitutablePathInfos(const StorePathSet & paths,
const std::set<ContentAddress> & caPaths,
const std::set<StorePathDescriptor> & caPaths,
SubstitutablePathInfos & infos) { return; };

/* Import a path into the store. */
Expand Down Expand Up @@ -749,6 +749,6 @@ std::optional<ValidPathInfo> decodeValidPathInfo(
/* Split URI into protocol+hierarchy part and its parameter set. */
std::pair<std::string, Store::Params> splitUriAndParams(const std::string & uri);

std::optional<ContentAddress> getDerivationCA(const BasicDerivation & drv);
std::optional<StorePathDescriptor> getDerivationCA(const BasicDerivation & drv);

}
4 changes: 2 additions & 2 deletions src/libstore/worker-protocol.hh
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ template<class T> T readStorePaths(const Store & store, Source & from);

void writeStorePaths(const Store & store, Sink & out, const StorePathSet & paths);

std::set<ContentAddress> readContentAddressSet(const Store & store, Source & from);
std::set<StorePathDescriptor> readContentAddressSet(const Store & store, Source & from);

void writeContentAddressSet(const Store & store, Sink & out, const std::set<ContentAddress> & paths);
void writeContentAddressSet(const Store & store, Sink & out, const std::set<StorePathDescriptor> & paths);

void writeOutputPathMap(const Store & store, Sink & out, const OutputPathMap & paths);

Expand Down
2 changes: 1 addition & 1 deletion src/nix/add-to-store.cc
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ struct CmdAddToStore : MixDryRun, StoreCommand

ValidPathInfo info {
*store,
ContentAddress {
StorePathDescriptor {
.name = *namePart,
.info = FixedOutputInfo {
{
Expand Down
2 changes: 1 addition & 1 deletion src/nix/make-content-addressable.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ struct CmdMakeContentAddressable : StorePathsCommand, MixJSON

ValidPathInfo info {
*store,
ContentAddress {
StorePathDescriptor {
.name = std::string { path.name() },
.info = FixedOutputInfo {
{
Expand Down

0 comments on commit ff07296

Please sign in to comment.