fix + random doc id

This commit is contained in:
2023-11-03 15:51:32 +01:00
parent a1bf480b82
commit 7fff379d88
3 changed files with 19 additions and 4 deletions

View File

@@ -1,6 +1,8 @@
#include "./crdtnotes.hpp"
CRDTNotes::CRDTNotes(void) {
_rng.seed(std::random_device{}());
_rng.discard(707);
}
CRDTNotes::~CRDTNotes(void) {
@@ -37,3 +39,13 @@ CRDTNotes::Doc* CRDTNotes::addDoc(const CRDTAgent& self_agent, const DocID& id)
return &doc;
}
CRDTNotes::Doc* CRDTNotes::addDoc(const CRDTAgent& self_agent) {
DocID new_id;
for (auto& it : new_id) {
// TODO: this discards alot
it = static_cast<uint8_t>(_rng());
}
return addDoc(self_agent, new_id);
}