#pragma once #include #include #include #include #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; }; }