aboutsummaryrefslogtreecommitdiff
path: root/zenstore/compactcas.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'zenstore/compactcas.cpp')
-rw-r--r--zenstore/compactcas.cpp60
1 files changed, 31 insertions, 29 deletions
diff --git a/zenstore/compactcas.cpp b/zenstore/compactcas.cpp
index 3b22f5b20..5aed02e7f 100644
--- a/zenstore/compactcas.cpp
+++ b/zenstore/compactcas.cpp
@@ -336,35 +336,37 @@ CasContainerStrategy::Scrub(ScrubContext& Ctx)
}
}
- m_BlockStore.IterateChunks(
- ChunkLocations,
- [&](size_t ChunkIndex, const void* Data, uint64_t Size) {
- const IoHash& Hash = ChunkIndexToChunkHash[ChunkIndex];
- if (!Data)
- {
- // ChunkLocation out of range of stored blocks
- BadKeys.push_back(Hash);
- return;
- }
- const IoHash ComputedHash = IoHash::HashBuffer(Data, Size);
- if (ComputedHash != Hash)
- {
- // Hash mismatch
- BadKeys.push_back(Hash);
- return;
- }
- },
- [&](size_t ChunkIndex, BlockStoreFile& File, uint64_t Offset, uint64_t Size) {
- IoHashStream Hasher;
- File.StreamByteRange(Offset, Size, [&](const void* Data, uint64_t Size) { Hasher.Append(Data, Size); });
- IoHash ComputedHash = Hasher.GetHash();
- const IoHash& Hash = ChunkIndexToChunkHash[ChunkIndex];
- if (ComputedHash != Hash)
- {
- // Hash mismatch
- BadKeys.push_back(Hash);
- }
- });
+ const auto ValidateSmallChunk = [&](size_t ChunkIndex, const void* Data, uint64_t Size) {
+ const IoHash& Hash = ChunkIndexToChunkHash[ChunkIndex];
+ if (!Data)
+ {
+ // ChunkLocation out of range of stored blocks
+ BadKeys.push_back(Hash);
+ return;
+ }
+ const IoHash ComputedHash = IoHash::HashBuffer(Data, Size);
+ if (ComputedHash != Hash)
+ {
+ // Hash mismatch
+ BadKeys.push_back(Hash);
+ return;
+ }
+ };
+
+ const auto ValidateLargeChunk = [&](size_t ChunkIndex, BlockStoreFile& File, uint64_t Offset, uint64_t Size) {
+ IoHashStream Hasher;
+ File.StreamByteRange(Offset, Size, [&](const void* Data, uint64_t Size) { Hasher.Append(Data, Size); });
+ IoHash ComputedHash = Hasher.GetHash();
+ const IoHash& Hash = ChunkIndexToChunkHash[ChunkIndex];
+ if (ComputedHash != Hash)
+ {
+ // Hash mismatch
+ BadKeys.push_back(Hash);
+ return;
+ }
+ };
+
+ m_BlockStore.IterateChunks(ChunkLocations, ValidateSmallChunk, ValidateLargeChunk);
_.ReleaseNow();