forked from zbackup/zbackup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
chunk_id.hh
40 lines (28 loc) · 983 Bytes
/
chunk_id.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Copyright (c) 2012-2014 Konstantin Isakov <[email protected]> and ZBackup contributors, see CONTRIBUTORS
// Part of ZBackup. Licensed under GNU GPLv2 or later + OpenSSL, see LICENSE
#ifndef CHUNK_ID_HH_INCLUDED
#define CHUNK_ID_HH_INCLUDED
#include <string>
#include "rolling_hash.hh"
using std::string;
/// Chunk is identified by its crypto hash concatenated with its rolling hash
struct ChunkId
{
typedef char CryptoHashPart[ 16 ];
CryptoHashPart cryptoHash;
typedef RollingHash::Digest RollingHashPart;
RollingHashPart rollingHash;
enum
{
BlobSize = sizeof( CryptoHashPart ) + sizeof( RollingHashPart )
};
string toBlob() const;
/// Faster version - should point to a buffer with at least BlobSize bytes
void toBlob( void * ) const;
/// Set the chunk id data reading from the given blob
void setFromBlob( void const * );
ChunkId() {}
ChunkId( string const & blob );
};
bool operator <( const ChunkId &lhs, const ChunkId &rhs );
#endif