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

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:
Eelco Dolstra 2016-04-20 14:12:38 +02:00
parent e0204f8d46
commit 451ebf24ce
18 changed files with 380 additions and 36 deletions

View file

@ -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);