max indexed tag size

This commit is contained in:
Doug Hoyte
2023-02-08 06:03:54 -05:00
parent d6df5c65b1
commit b32999cee8
6 changed files with 13 additions and 10 deletions

View File

@ -3,3 +3,4 @@
const uint64_t CURR_DB_VERSION = 1;
const size_t MAX_SUBID_SIZE = 71; // Statically allocated size in SubId
const uint64_t MAX_TIMESTAMP = 17179869184; // Safety limit to ensure it can fit in quadrable key. Good until year 2514.
const size_t MAX_INDEXED_TAG_VAL_SIZE = 255;

View File

@ -40,12 +40,14 @@ std::string nostrJsonToFlat(const tao::json::value &v) {
} else {
if (tagVal.size() < 1 || tagVal.size() > cfg().events__maxTagValSize) throw herr("tag val too small/large: ", tagVal.size());
if (tagVal.size() <= MAX_INDEXED_TAG_VAL_SIZE) {
tagsGeneral.emplace_back(NostrIndex::CreateTagGeneral(builder,
(uint8_t)tagName[0],
builder.CreateVector((uint8_t*)tagVal.data(), tagVal.size())
));
}
}
}
// Create flatbuffer

View File

@ -5,7 +5,6 @@
#include "golpe.h"
#include "Decompressor.h"
#include "constants.h"

View File

@ -2,8 +2,6 @@
#include "golpe.h"
#include "constants.h"
struct FilterSetBytes {
struct Item {
@ -18,6 +16,8 @@ struct FilterSetBytes {
// Sizes are post-hex decode
FilterSetBytes(const tao::json::value &arrHex, bool hexDecode, size_t minSize, size_t maxSize) {
if (maxSize > MAX_INDEXED_TAG_VAL_SIZE) throw herr("maxSize bigger than max indexed tag size");
std::vector<std::string> arr;
for (const auto &i : arrHex.get_array()) {
@ -145,7 +145,7 @@ struct NostrFilter {
if (tag == 'p' || tag == 'e') {
tags.emplace(tag, FilterSetBytes(v, true, 32, 32));
} else {
tags.emplace(tag, FilterSetBytes(v, false, 1, cfg().events__maxTagValSize));
tags.emplace(tag, FilterSetBytes(v, false, 1, MAX_INDEXED_TAG_VAL_SIZE));
}
} else {
throw herr("unindexed tag filter");

View File

@ -13,3 +13,6 @@ quadrable::Quadrable getQdbInstance();
std::string renderIP(std::string_view ipBytes);
#include "constants.h"

View File

@ -5,8 +5,6 @@
#include "golpe.h"
#include "constants.h"
static void dbCheck(lmdb::txn &txn, const std::string &cmd) {
auto dbTooOld = [&](uint64_t ver) {