nostrdb

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

commit da79a2b50f2635c232e5b19be854496554dbbebb
parent 9936d1576bed79c10a449f9db5f4e769e8aacee9
Author: William Casarin <jb55@jb55.com>
Date:   Tue, 27 Aug 2024 11:46:40 +0300

Merge remote-tracking branch 'github/pr/43'

Pull some fixes from rusty related to ndb_builder_find_str. It seems to
be matching prefixes instead of entire strings.

Rusty Russell (3):
      Makefile: fix header dependencies.
      content_parser: fix incorrect comment.
      nostrdb: fix ndb_builder_find_str.

Diffstat:
MMakefile | 4+++-
Msrc/content_parser.c | 2+-
Msrc/nostrdb.c | 2+-
3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile @@ -33,7 +33,9 @@ CHECKDATA=testdata/db/v0/data.mdb all: $(BIN) lib bench -%.o: %.c $(HEADERS) +$(OBJS): $(HEADERS) + +%.o: %.c $(CC) $(CFLAGS) -c -o $@ $< libnostrdb.a: $(OBJS) diff --git a/src/content_parser.c b/src/content_parser.c @@ -91,8 +91,8 @@ static int parse_hashtag(struct cursor *cur, struct ndb_block *block) { // // bech32 blocks are stored as: // -// nostr_bech32_type : varint // bech32_buffer_size : u16 +// nostr_bech32_type : varint // bech32_data : [u8] // // The TLV form is compact already, so we just use it directly diff --git a/src/nostrdb.c b/src/nostrdb.c @@ -5071,7 +5071,7 @@ static inline int ndb_builder_find_str(struct ndb_builder *builder, uint32_t index = ((uint32_t*)builder->str_indices.start)[i]; const char *some_str = (const char*)builder->strings.start + index; - if (!memcmp(some_str, str, len)) { + if (!memcmp(some_str, str, len) && some_str[len] == '\0') { // found an existing matching str, use that index *pstr = ndb_offset_str(index); return 1;