mirror of
https://github.com/hoytech/strfry.git
synced 2025-06-18 01:08:51 +00:00
max indexed tag size
This commit is contained in:
@ -3,3 +3,4 @@
|
|||||||
const uint64_t CURR_DB_VERSION = 1;
|
const uint64_t CURR_DB_VERSION = 1;
|
||||||
const size_t MAX_SUBID_SIZE = 71; // Statically allocated size in SubId
|
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 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;
|
||||||
|
@ -40,10 +40,12 @@ std::string nostrJsonToFlat(const tao::json::value &v) {
|
|||||||
} else {
|
} else {
|
||||||
if (tagVal.size() < 1 || tagVal.size() > cfg().events__maxTagValSize) throw herr("tag val too small/large: ", tagVal.size());
|
if (tagVal.size() < 1 || tagVal.size() > cfg().events__maxTagValSize) throw herr("tag val too small/large: ", tagVal.size());
|
||||||
|
|
||||||
tagsGeneral.emplace_back(NostrIndex::CreateTagGeneral(builder,
|
if (tagVal.size() <= MAX_INDEXED_TAG_VAL_SIZE) {
|
||||||
(uint8_t)tagName[0],
|
tagsGeneral.emplace_back(NostrIndex::CreateTagGeneral(builder,
|
||||||
builder.CreateVector((uint8_t*)tagVal.data(), tagVal.size())
|
(uint8_t)tagName[0],
|
||||||
));
|
builder.CreateVector((uint8_t*)tagVal.data(), tagVal.size())
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
#include "golpe.h"
|
#include "golpe.h"
|
||||||
|
|
||||||
#include "Decompressor.h"
|
#include "Decompressor.h"
|
||||||
#include "constants.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
#include "golpe.h"
|
#include "golpe.h"
|
||||||
|
|
||||||
#include "constants.h"
|
|
||||||
|
|
||||||
|
|
||||||
struct FilterSetBytes {
|
struct FilterSetBytes {
|
||||||
struct Item {
|
struct Item {
|
||||||
@ -18,6 +16,8 @@ struct FilterSetBytes {
|
|||||||
// Sizes are post-hex decode
|
// Sizes are post-hex decode
|
||||||
|
|
||||||
FilterSetBytes(const tao::json::value &arrHex, bool hexDecode, size_t minSize, size_t maxSize) {
|
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;
|
std::vector<std::string> arr;
|
||||||
|
|
||||||
for (const auto &i : arrHex.get_array()) {
|
for (const auto &i : arrHex.get_array()) {
|
||||||
@ -145,7 +145,7 @@ struct NostrFilter {
|
|||||||
if (tag == 'p' || tag == 'e') {
|
if (tag == 'p' || tag == 'e') {
|
||||||
tags.emplace(tag, FilterSetBytes(v, true, 32, 32));
|
tags.emplace(tag, FilterSetBytes(v, true, 32, 32));
|
||||||
} else {
|
} else {
|
||||||
tags.emplace(tag, FilterSetBytes(v, false, 1, cfg().events__maxTagValSize));
|
tags.emplace(tag, FilterSetBytes(v, false, 1, MAX_INDEXED_TAG_VAL_SIZE));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw herr("unindexed tag filter");
|
throw herr("unindexed tag filter");
|
||||||
|
@ -13,3 +13,6 @@ quadrable::Quadrable getQdbInstance();
|
|||||||
|
|
||||||
|
|
||||||
std::string renderIP(std::string_view ipBytes);
|
std::string renderIP(std::string_view ipBytes);
|
||||||
|
|
||||||
|
|
||||||
|
#include "constants.h"
|
||||||
|
@ -5,8 +5,6 @@
|
|||||||
|
|
||||||
#include "golpe.h"
|
#include "golpe.h"
|
||||||
|
|
||||||
#include "constants.h"
|
|
||||||
|
|
||||||
|
|
||||||
static void dbCheck(lmdb::txn &txn, const std::string &cmd) {
|
static void dbCheck(lmdb::txn &txn, const std::string &cmd) {
|
||||||
auto dbTooOld = [&](uint64_t ver) {
|
auto dbTooOld = [&](uint64_t ver) {
|
||||||
|
Reference in New Issue
Block a user