36 lines
821 B
C++
36 lines
821 B
C++
#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:
|
|
static constexpr const uint8_t p_size{32};
|
|
uint8_t pool;
|
|
static unsigned int source_id;
|
|
static accumulator::Pool pools[p_size];
|
|
|
|
public:
|
|
EventAdderImpl(const unsigned int source_id,
|
|
const accumulator::Pool pools[32]) {
|
|
this->source_id = source_id;
|
|
for (unsigned int i = 0; i < this->p_size; i++) {
|
|
this->pools[i] = pools[i];
|
|
}
|
|
this->pool = 0;
|
|
}
|
|
|
|
void add(std::vector<char> event) override {
|
|
this->pool = (this->pool + 1) % p_size;
|
|
pools[this->pool].add_entropy(source_id, event);
|
|
}
|
|
};
|
|
|
|
} // namespace accumulator
|
|
} // namespace fortuna
|
|
#endif // FORTUNA_EVENT_ADDER_IMPL_H
|