Cache path info lookups in SQLite
This re-implements the binary cache database in C++, allowing it to be used by other Store backends, in particular the S3 backend.
This commit is contained in:
+11
-1
@@ -7,6 +7,9 @@
|
||||
namespace nix {
|
||||
|
||||
|
||||
MakeError(BadHash, Error);
|
||||
|
||||
|
||||
enum HashType : char { htUnknown, htMD5, htSHA1, htSHA256, htSHA512 };
|
||||
|
||||
|
||||
@@ -26,12 +29,15 @@ struct Hash
|
||||
|
||||
HashType type;
|
||||
|
||||
/* Create an unusable hash object. */
|
||||
/* Create an unset hash object. */
|
||||
Hash();
|
||||
|
||||
/* Create a zero-filled hash object. */
|
||||
Hash(HashType type);
|
||||
|
||||
/* Check whether a hash is set. */
|
||||
operator bool () const { return type != htUnknown; }
|
||||
|
||||
/* Check whether two hash are equal. */
|
||||
bool operator == (const Hash & h2) const;
|
||||
|
||||
@@ -52,12 +58,16 @@ struct Hash
|
||||
{
|
||||
return (hashSize * 8 - 1) / 5 + 1;
|
||||
}
|
||||
|
||||
std::string to_string(bool base32 = true) const;
|
||||
};
|
||||
|
||||
|
||||
/* Convert a hash to a hexadecimal representation. */
|
||||
string printHash(const Hash & hash);
|
||||
|
||||
Hash parseHash(const string & s);
|
||||
|
||||
/* Parse a hexadecimal representation of a hash code. */
|
||||
Hash parseHash(HashType ht, const string & s);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user