aboutsummaryrefslogtreecommitdiff
path: root/zenstore
diff options
context:
space:
mode:
authorMartin Ridgers <[email protected]>2021-09-16 17:08:01 +0200
committerMartin Ridgers <[email protected]>2021-09-16 17:08:01 +0200
commit8da2c13a34fd6394aecaf19490d65a8a84592e3c (patch)
tree702cb3aec8145209fb5d8e39d8bf6d1432dd1a33 /zenstore
parentAnother missing include (diff)
parentCompact binary package caching support (#9) (diff)
downloadzen-8da2c13a34fd6394aecaf19490d65a8a84592e3c.tar.xz
zen-8da2c13a34fd6394aecaf19490d65a8a84592e3c.zip
Merge main into linux-mac
Diffstat (limited to 'zenstore')
-rw-r--r--zenstore/cidstore.cpp13
-rw-r--r--zenstore/include/zenstore/cidstore.h17
2 files changed, 19 insertions, 11 deletions
diff --git a/zenstore/cidstore.cpp b/zenstore/cidstore.cpp
index e6c7f98ee..100054a0e 100644
--- a/zenstore/cidstore.cpp
+++ b/zenstore/cidstore.cpp
@@ -28,15 +28,16 @@ struct CidStore::CidState
RwLock m_Lock;
tsl::robin_map<IoHash, IoHash> m_CidMap;
- CasStore::InsertResult AddChunk(CompressedBuffer& ChunkData)
+ CidStore::InsertResult AddChunk(CompressedBuffer& ChunkData)
{
- IoBuffer Payload = ChunkData.GetCompressed().Flatten().AsIoBuffer();
- IoHash CompressedHash = IoHash::HashBuffer(Payload.Data(), Payload.Size());
+ const IoHash DecompressedId = IoHash::FromBLAKE3(ChunkData.GetRawHash());
+ IoBuffer Payload = ChunkData.GetCompressed().Flatten().AsIoBuffer();
+ IoHash CompressedHash = IoHash::HashBuffer(Payload.Data(), Payload.Size());
CasStore::InsertResult Result = m_CasStore.InsertChunk(Payload, CompressedHash);
- AddCompressedCid(IoHash::FromBLAKE3(ChunkData.GetRawHash()), CompressedHash);
+ AddCompressedCid(DecompressedId, CompressedHash);
- return Result;
+ return {.DecompressedId = DecompressedId, .CompressedHash = CompressedHash, .New = Result.New};
}
void AddCompressedCid(const IoHash& DecompressedId, const IoHash& Compressed)
@@ -103,7 +104,7 @@ CidStore::~CidStore()
{
}
-CasStore::InsertResult
+CidStore::InsertResult
CidStore::AddChunk(CompressedBuffer& ChunkData)
{
return m_Impl->AddChunk(ChunkData);
diff --git a/zenstore/include/zenstore/cidstore.h b/zenstore/include/zenstore/cidstore.h
index 62d642ad1..76a33c915 100644
--- a/zenstore/include/zenstore/cidstore.h
+++ b/zenstore/include/zenstore/cidstore.h
@@ -31,11 +31,18 @@ public:
CidStore(CasStore& InCasStore, const std::filesystem::path& RootDir);
~CidStore();
- CasStore::InsertResult AddChunk(CompressedBuffer& ChunkData);
- void AddCompressedCid(const IoHash& DecompressedId, const IoHash& Compressed);
- IoBuffer FindChunkByCid(const IoHash& DecompressedId);
- bool ContainsChunk(const IoHash& DecompressedId);
- void Flush();
+ struct InsertResult
+ {
+ IoHash DecompressedId;
+ IoHash CompressedHash;
+ bool New = false;
+ };
+
+ InsertResult AddChunk(CompressedBuffer& ChunkData);
+ void AddCompressedCid(const IoHash& DecompressedId, const IoHash& Compressed);
+ IoBuffer FindChunkByCid(const IoHash& DecompressedId);
+ bool ContainsChunk(const IoHash& DecompressedId);
+ void Flush();
// TODO: add batch filter support