Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ValidPath (nar) hash optional if ca field is present #4059

Draft
wants to merge 18 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix and outline some comparison operators
  • Loading branch information
Ericson2314 committed Sep 24, 2020
commit 7bf6cdb003b3b5c18e608449d1b154dd91adf0e6
18 changes: 18 additions & 0 deletions src/libstore/content-address.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@

namespace nix {

bool TextHash::operator ==(const TextHash & otherHash) const noexcept {
return hash == otherHash.hash;
};

bool TextHash::operator !=(const TextHash & otherHash) const noexcept {
return hash != otherHash.hash;
};


bool FixedOutputHash::operator ==(const FixedOutputHash & otherHash) const noexcept {
return method == otherHash.method && hash == otherHash.hash;
};

bool FixedOutputHash::operator !=(const FixedOutputHash & otherHash) const noexcept {
return method != otherHash.method || hash != otherHash.hash;
};


std::string FixedOutputHash::printMethodAlgo() const
{
return makeFileIngestionPrefix(method) + printHashType(hash.type);
Expand Down
16 changes: 4 additions & 12 deletions src/libstore/content-address.hh
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,16 @@ enum struct FileIngestionMethod : uint8_t {

struct TextHash {
Hash hash;
bool operator ==(TextHash otherHash) const noexcept {
return hash == otherHash.hash;
};
bool operator !=(TextHash otherHash) const noexcept {
return hash != otherHash.hash;
};
bool operator ==(const TextHash & otherHash) const noexcept;
bool operator !=(const TextHash & otherHash) const noexcept;
};

/// Pair of a hash, and how the file system was ingested
struct FixedOutputHash {
FileIngestionMethod method;
Hash hash;
bool operator ==(FixedOutputHash otherHash) const noexcept {
return method == otherHash.method && hash == otherHash.hash;
};
bool operator !=(FixedOutputHash otherHash) const noexcept {
return method != otherHash.method && hash == otherHash.hash;
};
bool operator ==(const FixedOutputHash & therHash) const noexcept;
bool operator !=(const FixedOutputHash & therHash) const noexcept;
std::string printMethodAlgo() const;
};

Expand Down