fortuna: add moar_random_data() fun
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
fab8e72975
commit
3fe5c06c49
22
fortuna.cpp
22
fortuna.cpp
@ -118,6 +118,28 @@ auto Fortuna::random_data(const uint64_t n_bytes) -> void {
|
||||
fmt::print(stderr, "getting random data took {:.{}f}s\n", diff.count(), 12);
|
||||
} // random_data
|
||||
|
||||
auto Fortuna::moar_random_data(const uint64_t& n_bytes) -> void {
|
||||
// used for requests of more than 2^20 bytes
|
||||
// modus operandi: calculate how many consecutive requests to
|
||||
// "random_data(2^20)" are needed, call random_data() until done
|
||||
|
||||
if (n_bytes > Fortuna::two_pow_twenty) {
|
||||
uint64_t how_many_ops{n_bytes / Fortuna::two_pow_twenty};
|
||||
|
||||
uint64_t remaining{n_bytes};
|
||||
fmt::print(stderr, "[i] fortuna: remaining {} bytes\n", remaining);
|
||||
while (--how_many_ops > 0) {
|
||||
this->random_data(Fortuna::two_pow_twenty);
|
||||
remaining -= Fortuna::two_pow_twenty;
|
||||
fmt::print(stderr, "[i] fortuna: remaining {} bytes\n", remaining);
|
||||
}
|
||||
this->random_data(remaining);
|
||||
}
|
||||
else {
|
||||
this->random_data(n_bytes);
|
||||
}
|
||||
} // moar_random_data
|
||||
|
||||
|
||||
auto Fortuna::seed_file_manager_service() -> void {
|
||||
static constexpr const std::chrono::seconds checkup_interval{7};
|
||||
|
@ -36,6 +36,8 @@ public:
|
||||
~Fortuna() noexcept;
|
||||
|
||||
[[optimize_for_synchronized]] auto random_data(const uint64_t) -> void;
|
||||
[[optimize_for_synchronized]] auto moar_random_data(const uint64_t&)
|
||||
-> void;
|
||||
|
||||
auto set_reseed_ctr_to_null() -> void {
|
||||
std::scoped_lock sl(mtx_accu, print_mtx);
|
||||
|
Reference in New Issue
Block a user