diff options
Diffstat (limited to 'src/zenserver/projectstore/remoteprojectstore.h')
| -rw-r--r-- | src/zenserver/projectstore/remoteprojectstore.h | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/src/zenserver/projectstore/remoteprojectstore.h b/src/zenserver/projectstore/remoteprojectstore.h index f0655fb59..e05cb9923 100644 --- a/src/zenserver/projectstore/remoteprojectstore.h +++ b/src/zenserver/projectstore/remoteprojectstore.h @@ -16,6 +16,14 @@ struct ChunkedInfo; class RemoteProjectStore { public: + struct Block + { + IoHash BlockHash; + std::vector<IoHash> ChunkHashes; + std::vector<uint32_t> ChunkLengths; + uint32_t FirstChunkOffset = (uint32_t)-1; + }; + struct Result { int32_t ErrorCode{}; @@ -24,6 +32,10 @@ public: std::string Text; }; + struct CreateContainerResult : public Result + { + }; + struct SaveResult : public Result { std::unordered_set<IoHash, IoHash::Hasher> Needs; @@ -43,11 +55,6 @@ public: { }; - struct HasAttachmentsResult : public Result - { - std::unordered_set<IoHash, IoHash::Hasher> Needs; - }; - struct LoadAttachmentResult : public Result { IoBuffer Bytes; @@ -63,13 +70,17 @@ public: std::vector<std::pair<IoHash, CompressedBuffer>> Chunks; }; + struct GetKnownBlocksResult : public Result + { + std::vector<Block> Blocks; + }; + struct RemoteStoreInfo { bool CreateBlocks; bool UseTempBlockFiles; bool AllowChunking; std::string ContainerName; - std::string BaseContainerName; std::string Description; }; @@ -90,15 +101,15 @@ public: virtual RemoteStoreInfo GetInfo() const = 0; virtual Stats GetStats() const = 0; - virtual SaveResult SaveContainer(const IoBuffer& Payload) = 0; - virtual SaveAttachmentResult SaveAttachment(const CompositeBuffer& Payload, const IoHash& RawHash) = 0; - virtual FinalizeResult FinalizeContainer(const IoHash& RawHash) = 0; - virtual SaveAttachmentsResult SaveAttachments(const std::vector<SharedBuffer>& Payloads) = 0; + virtual CreateContainerResult CreateContainer() = 0; + virtual SaveResult SaveContainer(const IoBuffer& Payload) = 0; + virtual SaveAttachmentResult SaveAttachment(const CompositeBuffer& Payload, const IoHash& RawHash, Block&& Block) = 0; + virtual FinalizeResult FinalizeContainer(const IoHash& RawHash) = 0; + virtual SaveAttachmentsResult SaveAttachments(const std::vector<SharedBuffer>& Payloads) = 0; virtual LoadContainerResult LoadContainer() = 0; - virtual LoadContainerResult LoadBaseContainer() = 0; + virtual GetKnownBlocksResult GetKnownBlocks() = 0; virtual LoadAttachmentResult LoadAttachment(const IoHash& RawHash) = 0; - virtual HasAttachmentsResult HasAttachments(const std::span<IoHash> RawHashes) = 0; virtual LoadAttachmentsResult LoadAttachments(const std::vector<IoHash>& RawHashes) = 0; }; @@ -126,7 +137,7 @@ RemoteProjectStore::LoadContainerResult BuildContainer( bool BuildBlocks, bool IgnoreMissingAttachments, bool AllowChunking, - const std::function<void(CompressedBuffer&&, const IoHash&)>& AsyncOnBlock, + const std::function<void(CompressedBuffer&&, RemoteProjectStore::Block&&)>& AsyncOnBlock, const std::function<void(const IoHash&, TGetAttachmentBufferFunc&&)>& OnLargeAttachment, const std::function<void(std::vector<std::pair<IoHash, FetchChunkFunc>>&&)>& OnBlockChunks, bool EmbedLooseFiles); @@ -162,7 +173,9 @@ RemoteProjectStore::Result LoadOplog(CidStore& ChunkStore, bool CleanOplog, JobContext* OptionalContext); -CompressedBuffer GenerateBlock(std::vector<std::pair<IoHash, FetchChunkFunc>>&& FetchChunks); +CompressedBuffer GenerateBlock(std::vector<std::pair<IoHash, FetchChunkFunc>>&& FetchChunks, RemoteProjectStore::Block& OutBlock); bool IterateBlock(const SharedBuffer& BlockPayload, std::function<void(CompressedBuffer&& Chunk, const IoHash& AttachmentHash)> Visitor); +std::vector<IoHash> GetBlockHashesFromOplog(CbObjectView ContainerObject); +std::vector<RemoteProjectStore::Block> GetBlocksFromOplog(CbObjectView ContainerObject, std::span<const IoHash> IncludeBlockHashes); } // namespace zen |