aboutsummaryrefslogtreecommitdiff
path: root/src/libstore
diff options
context:
space:
mode:
authorCarlo Nucera <carlo.nucera@protonmail.com>2020-07-01 18:34:18 -0400
committerCarlo Nucera <carlo.nucera@protonmail.com>2020-07-01 18:34:18 -0400
commit263ccdd48923b730fd7e6f687583160d7b24039b (patch)
tree156305c1928adae6f67ff1aacd2c55a0a0097a24 /src/libstore
parentc8c4bcf90e065b47c3ee2984b1f8ff696da889af (diff)
Rename two hash constructors to proper functions
Diffstat (limited to 'src/libstore')
-rw-r--r--src/libstore/content-address.cc4
-rw-r--r--src/libstore/daemon.cc2
-rw-r--r--src/libstore/derivations.cc4
-rw-r--r--src/libstore/legacy-ssh-store.cc2
-rw-r--r--src/libstore/local-store.cc2
-rw-r--r--src/libstore/nar-info-disk-cache.cc4
-rw-r--r--src/libstore/nar-info.cc2
-rw-r--r--src/libstore/remote-store.cc2
-rw-r--r--src/libstore/store-api.cc2
9 files changed, 12 insertions, 12 deletions
diff --git a/src/libstore/content-address.cc b/src/libstore/content-address.cc
index 8152e5215..2d96fb0c0 100644
--- a/src/libstore/content-address.cc
+++ b/src/libstore/content-address.cc
@@ -68,7 +68,7 @@ ContentAddress parseContentAddress(std::string_view rawCa) {
throw Error("text content address hash should use %s, but instead uses %s",
printHashType(htSHA256), printHashType(hashType));
return TextHash {
- .hash = Hash { rest, std::move(hashType) },
+ .hash = Hash::parseAny(rest, std::move(hashType)),
};
} else if (prefix == "fixed") {
// Parse method
@@ -80,7 +80,7 @@ ContentAddress parseContentAddress(std::string_view rawCa) {
HashType hashType = parseHashType_();
return FixedOutputHash {
.method = method,
- .hash = Hash { rest, std::move(hashType) },
+ .hash = Hash::parseAny(rest, std::move(hashType)),
};
} else
throw UsageError("content address prefix \"%s\" is unrecognized. Recogonized prefixes are \"text\" or \"fixed\"", prefix);
diff --git a/src/libstore/daemon.cc b/src/libstore/daemon.cc
index 0b48e04c0..cc4827e64 100644
--- a/src/libstore/daemon.cc
+++ b/src/libstore/daemon.cc
@@ -706,7 +706,7 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
auto deriver = readString(from);
if (deriver != "")
info.deriver = store->parseStorePath(deriver);
- info.narHash = Hash(readString(from), htSHA256);
+ info.narHash = Hash::parseAny(readString(from), htSHA256);
info.references = readStorePaths<StorePathSet>(*store, from);
from >> info.registrationTime >> info.narSize >> info.ultimate;
info.sigs = readStrings<StringSet>(from);
diff --git a/src/libstore/derivations.cc b/src/libstore/derivations.cc
index 42551ef6b..30ce32354 100644
--- a/src/libstore/derivations.cc
+++ b/src/libstore/derivations.cc
@@ -118,7 +118,7 @@ static DerivationOutput parseDerivationOutput(const Store & store, istringstream
const HashType hashType = parseHashType(hashAlgo);
fsh = FixedOutputHash {
.method = std::move(method),
- .hash = Hash(hash, hashType),
+ .hash = Hash::parseAny(hash, hashType),
};
}
@@ -416,7 +416,7 @@ static DerivationOutput readDerivationOutput(Source & in, const Store & store)
auto hashType = parseHashType(hashAlgo);
fsh = FixedOutputHash {
.method = std::move(method),
- .hash = Hash(hash, hashType),
+ .hash = Hash::parseAny(hash, hashType),
};
}
diff --git a/src/libstore/legacy-ssh-store.cc b/src/libstore/legacy-ssh-store.cc
index 35caf23e7..f9d95fd2b 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() ? std::optional<Hash>{} : Hash{s};
+ info->narHash = s.empty() ? std::optional<Hash>{} : Hash::parseAnyPrefixed(s);
info->ca = parseContentAddressOpt(readString(conn->from));
info->sigs = readStrings<StringSet>(conn->from);
}
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc
index 9259d8f61..b75e2bdfe 100644
--- a/src/libstore/local-store.cc
+++ b/src/libstore/local-store.cc
@@ -647,7 +647,7 @@ void LocalStore::queryPathInfoUncached(const StorePath & path,
info->id = useQueryPathInfo.getInt(0);
try {
- info->narHash = Hash(useQueryPathInfo.getStr(1));
+ info->narHash = Hash::parseAnyPrefixed(useQueryPathInfo.getStr(1));
} catch (BadHash & e) {
throw Error("in valid-path entry for '%s': %s", printStorePath(path), e.what());
}
diff --git a/src/libstore/nar-info-disk-cache.cc b/src/libstore/nar-info-disk-cache.cc
index 9ddb9957f..92da14e23 100644
--- a/src/libstore/nar-info-disk-cache.cc
+++ b/src/libstore/nar-info-disk-cache.cc
@@ -193,9 +193,9 @@ public:
narInfo->url = queryNAR.getStr(2);
narInfo->compression = queryNAR.getStr(3);
if (!queryNAR.isNull(4))
- narInfo->fileHash = Hash(queryNAR.getStr(4));
+ narInfo->fileHash = Hash::parseAnyPrefixed(queryNAR.getStr(4));
narInfo->fileSize = queryNAR.getInt(5);
- narInfo->narHash = Hash(queryNAR.getStr(6));
+ narInfo->narHash = Hash::parseAnyPrefixed(queryNAR.getStr(6));
narInfo->narSize = queryNAR.getInt(7);
for (auto & r : tokenizeString<Strings>(queryNAR.getStr(8), " "))
narInfo->references.insert(StorePath(r));
diff --git a/src/libstore/nar-info.cc b/src/libstore/nar-info.cc
index c403d4bec..2a52e4098 100644
--- a/src/libstore/nar-info.cc
+++ b/src/libstore/nar-info.cc
@@ -12,7 +12,7 @@ NarInfo::NarInfo(const Store & store, const std::string & s, const std::string &
auto parseHashField = [&](const string & s) {
try {
- return Hash(s);
+ return Hash::parseAnyPrefixed(s);
} catch (BadHash &) {
throw corrupt();
}
diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc
index 305a47340..890d96388 100644
--- a/src/libstore/remote-store.cc
+++ b/src/libstore/remote-store.cc
@@ -375,7 +375,7 @@ void RemoteStore::queryPathInfoUncached(const StorePath & path,
info = std::make_shared<ValidPathInfo>(StorePath(path));
auto deriver = readString(conn->from);
if (deriver != "") info->deriver = parseStorePath(deriver);
- info->narHash = Hash(readString(conn->from), htSHA256);
+ info->narHash = Hash::parseAny(readString(conn->from), htSHA256);
info->references = readStorePaths<StorePathSet>(*this, conn->from);
conn->from >> info->registrationTime >> info->narSize;
if (GET_PROTOCOL_MINOR(conn->daemonVersion) >= 16) {
diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc
index e4083bbe1..080ce9823 100644
--- a/src/libstore/store-api.cc
+++ b/src/libstore/store-api.cc
@@ -703,7 +703,7 @@ std::optional<ValidPathInfo> decodeValidPathInfo(const Store & store, std::istre
if (hashGiven) {
string s;
getline(str, s);
- info.narHash = Hash(s, htSHA256);
+ info.narHash = Hash::parseAny(s, htSHA256);
getline(str, s);
if (!string2Int(s, info.narSize)) throw Error("number expected");
}