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.
2021-12-08 03:58:18 +01:00
|
|
|
#ifndef FORTUNA_EVENT_ADDER_IMPL_H
|
|
|
|
#define FORTUNA_EVENT_ADDER_IMPL_H
|
|
|
|
|
|
|
|
#include "event_adder.h"
|
|
|
|
#include "pool.h"
|
|
|
|
|
|
|
|
namespace fortuna {
|
|
|
|
namespace accumulator {
|
|
|
|
|
|
|
|
class EventAdderImpl final : public EventAdder {
|
|
|
|
private:
|
2021-12-08 04:14:54 +01:00
|
|
|
static constexpr const uint8_t p_size{32};
|
2021-12-11 20:16:24 +01:00
|
|
|
uint8_t pool;
|
2021-12-08 03:58:18 +01:00
|
|
|
static unsigned int source_id;
|
2021-12-08 04:14:54 +01:00
|
|
|
static accumulator::Pool pools[p_size];
|
2021-12-08 03:58:18 +01:00
|
|
|
|
|
|
|
public:
|
|
|
|
EventAdderImpl(const unsigned int source_id, const accumulator::Pool pools[32]) {
|
|
|
|
this->source_id = source_id;
|
2021-12-08 04:14:54 +01:00
|
|
|
for (unsigned int i = 0; i < this->p_size; i++) {
|
2021-12-08 03:58:18 +01:00
|
|
|
this->pools[i] = pools[i];
|
|
|
|
}
|
|
|
|
this->pool = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void add(std::vector<char> event) override {
|
2021-12-08 04:14:54 +01:00
|
|
|
this->pool = (this->pool + 1) % p_size;
|
2021-12-08 03:58:18 +01:00
|
|
|
pools[this->pool].add_entropy(source_id, event);
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
} //namespace accumulator
|
|
|
|
} //namespace fortuna
|
|
|
|
#endif//FORTUNA_EVENT_ADDER_IMPL_H
|