40 lines
891 B
C++
40 lines
891 B
C++
#ifndef FORTUNA_EVENT_ADDER_IMPL_H
|
|
#define FORTUNA_EVENT_ADDER_IMPL_H
|
|
|
|
#include "event_adder.h"
|
|
#include "pool.h"
|
|
|
|
#include <cstdint>
|
|
|
|
namespace fortuna {
|
|
namespace accumulator {
|
|
|
|
class EventAdderImpl final : public EventAdder {
|
|
public:
|
|
static constexpr const uint8_t p_size{32};
|
|
|
|
private:
|
|
uint8_t pool_id;
|
|
static unsigned int _source_id;
|
|
static accumulator::Pool _pools[p_size];
|
|
|
|
public:
|
|
EventAdderImpl(const unsigned int source_id,
|
|
const accumulator::Pool pools[p_size]) {
|
|
this->_source_id = source_id;
|
|
for (uint8_t i{0}; i < this->p_size; i++) {
|
|
this->_pools[i] = pools[i];
|
|
}
|
|
this->pool_id = 0;
|
|
}
|
|
|
|
void add(std::vector<char> event) override {
|
|
this->pool_id = static_cast<uint8_t>((this->pool_id + 1) % p_size);
|
|
_pools[this->pool_id].add_entropy(_source_id, event);
|
|
}
|
|
};
|
|
|
|
} // namespace accumulator
|
|
} // namespace fortuna
|
|
#endif // FORTUNA_EVENT_ADDER_IMPL_H
|