This repository has been archived on 2022-02-10. You can view files and clone it, but cannot push or open issues or pull requests.
fortuna/pool.h
surtur ebcc4f87d5
All checks were successful
continuous-integration/drone/push Build is passing
pool: move logic to the source file
2022-01-10 05:07:18 +01:00

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