1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-06 21:41:48 +02:00

WIP: store separate hasValidPath bool

This commit is contained in:
John Ericson 2020-06-24 22:46:27 +00:00
parent 1722ae6ece
commit 71e4c9c505
17 changed files with 119 additions and 69 deletions

View file

@ -24,8 +24,43 @@ template<typename Ref>
struct PathReferences
{
std::set<Ref> references;
bool hasSelfReference = false;
/* Functions to view references + hasSelfReference as one set, mainly for
compatibility's sake. */
StorePathSet referencesPossiblyToSelf(const Ref & self) const;
void insertReferencePossiblyToSelf(const Ref & self, Ref && ref);
void setReferencesPossiblyToSelf(const Ref & self, std::set<Ref> && refs);
};
template<typename Ref>
StorePathSet PathReferences<Ref>::referencesPossiblyToSelf(const Ref & self) const
{
StorePathSet references { references };
if (hasSelfReference)
references.insert(self);
return references;
}
template<typename Ref>
void PathReferences<Ref>::insertReferencePossiblyToSelf(const Ref & self, Ref && ref)
{
if (ref == self)
hasSelfReference = true;
else
references.insert(std::move(ref));
}
template<typename Ref>
void PathReferences<Ref>::setReferencesPossiblyToSelf(const Ref & self, std::set<Ref> && refs)
{
if (refs.count(self))
hasSelfReference = true;
refs.erase(self);
references = refs;
}
struct ValidPathInfo : PathReferences<StorePath>
{
StorePath path;
@ -64,6 +99,7 @@ struct ValidPathInfo : PathReferences<StorePath>
return
path == i.path
&& narHash == i.narHash
&& hasSelfReference == i.hasSelfReference
&& references == i.references;
}
@ -80,6 +116,12 @@ struct ValidPathInfo : PathReferences<StorePath>
/* Return true iff the path is verifiably content-addressed. */
bool isContentAddressed(const Store & store) const;
/* Functions to view references + hasSelfReference as one set, mainly for
compatibility's sake. */
StorePathSet referencesPossiblyToSelf() const;
void insertReferencePossiblyToSelf(StorePath && ref);
void setReferencesPossiblyToSelf(StorePathSet && refs);
static const size_t maxSigs = std::numeric_limits<size_t>::max();
/* Return the number of signatures on this .narinfo that were
@ -101,4 +143,14 @@ struct ValidPathInfo : PathReferences<StorePath>
};
typedef list<ValidPathInfo> ValidPathInfos;
struct SubstitutablePathInfo : PathReferences<StorePath>
{
std::optional<StorePath> deriver;
unsigned long long downloadSize; /* 0 = unknown or inapplicable */
unsigned long long narSize; /* 0 = unknown */
};
typedef std::map<StorePath, SubstitutablePathInfo> SubstitutablePathInfos;
}