mirror of
https://github.com/facebook/sapling.git
synced 2024-10-05 14:28:17 +03:00
3ae264c71c
Summary: Adding blake3 support to SerializedBlobMetadata. * The serialized data is stored as: * - version (1 byte, big endian) * - blob_size (up to 10 bytes, big endian) * - used_hashes (1 byte, big-endian) * - hashes stored in order of their type values e.g. from less significant to more significant * - hash (N bytes) ... * - hash (M bytes) Reviewed By: chadaustin Differential Revision: D44500908 fbshipit-source-id: d64081db8591f85be5cdf3fd98ff9839c028d5fb
55 lines
1.3 KiB
C++
55 lines
1.3 KiB
C++
/*
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* This software may be used and distributed according to the terms of the
|
|
* GNU General Public License version 2.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <optional>
|
|
|
|
#include <folly/Range.h>
|
|
|
|
#include "eden/fs/model/BlobMetadata.h"
|
|
#include "eden/fs/model/Hash.h"
|
|
#include "eden/fs/model/ObjectId.h"
|
|
#include "eden/fs/store/StoreResult.h"
|
|
|
|
namespace facebook::eden {
|
|
|
|
class SerializedBlobMetadata {
|
|
public:
|
|
explicit SerializedBlobMetadata(const BlobMetadata& metadata);
|
|
SerializedBlobMetadata(
|
|
const Hash20& sha1,
|
|
const std::optional<Hash32>& blake3,
|
|
uint64_t blobSize);
|
|
folly::ByteRange slice() const;
|
|
|
|
static BlobMetadataPtr parse(
|
|
const ObjectId& blobID,
|
|
const StoreResult& result);
|
|
|
|
private:
|
|
void serialize(
|
|
const Hash20& sha1,
|
|
const std::optional<Hash32>& blake3,
|
|
uint64_t blobSize);
|
|
|
|
/**
|
|
* The serialized data is stored as:
|
|
* - version (1 byte)
|
|
* - blob_size (varint, little endian)
|
|
* - used_hashes (varint, little endian)
|
|
* - hashes stored in order of their type values e.g. from less significant
|
|
to more significant
|
|
* - hash (N bytes)
|
|
...
|
|
* - hash (M bytes)
|
|
*/
|
|
std::pair<std::unique_ptr<uint8_t[]>, size_t> dataAndSize_;
|
|
};
|
|
|
|
} // namespace facebook::eden
|