blob: aba0a243dd11638a9477e924291c217f3d4ef574 (
plain)
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
|
#pragma once
#include <array>
#include <stdexcept>
#include <sibs/PubsubKey.hpp>
#include <cassert>
#include "types.hpp"
namespace odhtdb
{
class InfoHashException : public std::runtime_error
{
public:
InfoHashException(const std::string &errMsg) : std::runtime_error(errMsg) {}
};
class InfoHash
{
public:
InfoHash();
InfoHash(const u8 *data, const size_t size);
// Throws InfoHashException on error
static InfoHash generateHash(const u8 *data, const size_t size);
u8& operator [] (size_t index)
{
assert(index < key.data.size());
return key.data[index];
}
const sibs::PubsubKey& getKey() const { return key; }
bool operator == (const InfoHash &other) const;
bool operator != (const InfoHash &other) const;
private:
sibs::PubsubKey key;
};
}
|