nostrdb

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

commit 5b45c3b6c13cf3ecf446e4a226ece349193c7ac3
parent 6cc08c8526ed30d2f4bb63293711328f2cffa7b5
Author: William Casarin <jb55@jb55.com>
Date:   Fri, 28 Jun 2024 16:41:32 -0500

ndb_note_json: return length

Diffstat:
Msrc/nostrdb.c | 7++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/nostrdb.c b/src/nostrdb.c @@ -4756,7 +4756,7 @@ int ndb_note_json(struct ndb_note *note, char *buf, int buflen) make_cursor((unsigned char *)buf, (unsigned char*)buf + buflen, &cur); - return cursor_push_str(c, "{\"id\":\"") && + int ok = cursor_push_str(c, "{\"id\":\"") && cursor_push_hex(c, ndb_note_id(note), 32) && cursor_push_str(c, "\",\"pubkey\":\"") && cursor_push_hex(c, ndb_note_pubkey(note), 32) && @@ -4772,6 +4772,11 @@ int ndb_note_json(struct ndb_note *note, char *buf, int buflen) cursor_push_hex(c, ndb_note_sig(note), 64) && cursor_push_c_str(c, "\"}"); + if (!ok) { + return 0; + } + + return cur.p - cur.start; } int ndb_calculate_id(struct ndb_note *note, unsigned char *buf, int buflen) {