nostrdb

an unfairly fast embedded nostr database backed by lmdb
git clone git://jb55.com/nostrdb
Log | Files | Refs | Submodules | README | LICENSE

commit 6fee21b428578b931737ecdd29324084a1eaa86a
parent 8163bfed36e5bfaf4d9034d5e350b42d3fe15a56
Author: William Casarin <jb55@jb55.com>
Date:   Thu, 10 Aug 2023 12:07:05 -0700

idhack: make sure json parser in continable after we parse the id

Diffstat:
Mjsmn.h | 1+
Mnostrdb.c | 7++++---
2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/jsmn.h b/jsmn.h @@ -377,6 +377,7 @@ JSMN_API int jsmn_parse(jsmn_parser *parser, const char *js, const size_t len, token = &tokens[parser->toknext-1]; if (idkey == 1 && (token->end - token->start) == 64) { //printf("jsmn: found id '%.*s'\n", token->end - token->start, js + token->start); + parser->pos++; return -42; } else if (idkey == 0 && (token->end - token->start) == 2 && (js + token->start)[0] == 'i' && diff --git a/nostrdb.c b/nostrdb.c @@ -703,13 +703,14 @@ static inline int ndb_json_parser_parse(struct ndb_json_parser *p, case NDB_IDRES_STOP: return -42; } - } else { - p->num_tokens = res; + } else if (res == 0) { + return 0; } + p->num_tokens = res; p->i = 0; - return p->num_tokens; + return 1; } static int cursor_push_unescaped_char(struct cursor *cur, char c1, char c2)