From 129516a48f8824163dcf1124523b1c906749d449 Mon Sep 17 00:00:00 2001 From: surtur Date: Mon, 13 Dec 2021 05:59:27 +0100 Subject: [PATCH] add seed_file_management.h holding SeedFileManager --- CMakeLists.txt | 2 +- seed_file_management.h | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 seed_file_management.h diff --git a/CMakeLists.txt b/CMakeLists.txt index b15b150..31139b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -184,7 +184,7 @@ add_subdirectory(lib/da_threading EXCLUDE_FROM_ALL) endif(NOT CMAKE_EXE_LINKER_FLAGS MATCHES "-fuse-ld=lld") endif() -add_executable(fortuna main.cpp generator.cpp generator.h fortuna.cpp fortuna.h accumulator.cpp accumulator.h pool.cpp pool.h event_adder.h event_adder_impl.h event_scheduler.h entropy_src.h urandom_entropy_src.h do_task.cpp do_task.h util.h) +add_executable(fortuna main.cpp generator.cpp generator.h fortuna.cpp fortuna.h accumulator.cpp accumulator.h pool.cpp pool.h event_adder.h event_adder_impl.h event_scheduler.h entropy_src.h urandom_entropy_src.h do_task.cpp do_task.h util.h seed_file_management.h) # ref: https://cmake.org/pipermail/cmake/2016-May/063400.html target_link_libraries(fortuna PRIVATE cryptopp diff --git a/seed_file_management.h b/seed_file_management.h new file mode 100644 index 0000000..bb21c5c --- /dev/null +++ b/seed_file_management.h @@ -0,0 +1,37 @@ +#ifndef FORTUNA_SEED_FILE_MANAGER_H +#define FORTUNA_SEED_FILE_MANAGER_H + +#include +#include + +#include "accumulator.h" +#include "do_task.h" + +namespace fortuna { + +class SeedFileManager { +public: + struct conf + { + std::chrono::minutes write_interval{10}; + std::string seed_f_path = "./fortuna.seed"; + std::size_t seed_f_length = 64; + + conf(){}; + }; + +private: + const conf config; + DoTask do_task; + fortuna::accumulator::Accumulator& accumulator; + + auto write_seed_file() -> void; + auto update_seed_file() -> void; + +public: + SeedFileManager(conf config, fortuna::accumulator::Accumulator& accumulator); +}; // class SeedFileManager + +} // namespace fortuna + +#endif // FORTUNA_SEED_FILE_MANAGER_H