From 5e02fc9fa0a2480e608a72489baef5831b099460 Mon Sep 17 00:00:00 2001 From: Dan Engelbrecht Date: Fri, 22 Mar 2024 23:00:54 +0100 Subject: re-enable partial cache chunks (#21) * Separate chunk raw hash from section hash (how to find the fragment attachment) * fix partial get cache value tests --- src/zenutil/cache/cacherequests.cpp | 8 +++++--- src/zenutil/include/zenutil/cache/cacherequests.h | 9 +++++---- 2 files changed, 10 insertions(+), 7 deletions(-) (limited to 'src/zenutil') diff --git a/src/zenutil/cache/cacherequests.cpp b/src/zenutil/cache/cacherequests.cpp index 442cf0dfc..7c6f493f2 100644 --- a/src/zenutil/cache/cacherequests.cpp +++ b/src/zenutil/cache/cacherequests.cpp @@ -792,9 +792,11 @@ namespace cacherequests { bool Succeeded = !RawHashField.HasError(); if (Succeeded) { - ValueResult.RawOffset = RecordObject["RawOffset"].AsUInt64(0); - const CbAttachment* Attachment = Package.FindAttachment(ValueResult.RawHash); - ValueResult.Body = Attachment ? Attachment->AsCompressedBinary().MakeOwned() : CompressedBuffer(); + ValueResult.FragmentOffset = RecordObject["FragmentOffset"].AsUInt64(0); + ValueResult.FragmentHash = RecordObject["FragmentHash"].AsHash(); + const CbAttachment* Attachment = + Package.FindAttachment(ValueResult.FragmentHash == IoHash::Zero ? ValueResult.RawHash : ValueResult.FragmentHash); + ValueResult.Body = Attachment ? Attachment->AsCompressedBinary().MakeOwned() : CompressedBuffer(); if (ValueResult.Body) { ValueResult.RawSize = ValueResult.Body.DecodeRawSize(); diff --git a/src/zenutil/include/zenutil/cache/cacherequests.h b/src/zenutil/include/zenutil/cache/cacherequests.h index 0913efc65..fbf3e08cc 100644 --- a/src/zenutil/include/zenutil/cache/cacherequests.h +++ b/src/zenutil/include/zenutil/cache/cacherequests.h @@ -195,10 +195,11 @@ namespace cacherequests { struct CacheValueResult { - uint64_t RawSize = 0; - uint64_t RawOffset = 0; - IoHash RawHash = IoHash::Zero; - CompressedBuffer Body = CompressedBuffer::Null; + uint64_t RawSize = 0; + uint64_t FragmentOffset = 0; + IoHash FragmentHash = IoHash::Zero; + IoHash RawHash = IoHash::Zero; + CompressedBuffer Body = CompressedBuffer::Null; }; struct CacheValuesResult -- cgit v1.2.3