47 lines
881 B
C++
47 lines
881 B
C++
#ifndef FORTUNA_POOL_H
|
|
#define FORTUNA_POOL_H
|
|
|
|
#include "util.h"
|
|
|
|
#include <fmt/core.h>
|
|
#include <stdexcept>
|
|
|
|
namespace fortuna {
|
|
namespace accumulator {
|
|
|
|
class Pool {
|
|
public:
|
|
Pool() noexcept {};
|
|
Pool(const Pool& pool) = delete; // no copy
|
|
~Pool() noexcept = default;
|
|
|
|
auto set_id(unsigned int id) -> void;
|
|
|
|
auto get_id() const -> unsigned int;
|
|
|
|
auto initialize_pool(unsigned int id) -> void;
|
|
|
|
// add entropy contained in a random event of 1 to 32 bytes
|
|
auto add_entropy(const uint source, const std::vector<char>& event) -> int;
|
|
|
|
auto get_s_length() const -> uint64_t;
|
|
|
|
auto get_s() const -> std::string;
|
|
|
|
auto clear_pool() -> void;
|
|
|
|
protected:
|
|
auto append_s(const std::string& entropy_s) -> void;
|
|
|
|
private:
|
|
unsigned int pool_id{0};
|
|
std::string s{""};
|
|
uint64_t size{0};
|
|
|
|
}; // class Pool
|
|
|
|
} // namespace accumulator
|
|
} // namespace fortuna
|
|
|
|
#endif // FORTUNA_POOL_H
|