From 0847c53a39748fb862d3415e1df8125af65f7429 Mon Sep 17 00:00:00 2001 From: William Casarin Date: Thu, 3 Jul 2025 16:07:29 -0700 Subject: [PATCH] nostrdb: add ndb_builder_push_tag_id Signed-off-by: William Casarin --- nostrdb/src/nostrdb.c | 10 ++++++++++ nostrdb/src/nostrdb.h | 1 + 2 files changed, 11 insertions(+) diff --git a/nostrdb/src/nostrdb.c b/nostrdb/src/nostrdb.c index 29044e21..eff9609d 100644 --- a/nostrdb/src/nostrdb.c +++ b/nostrdb/src/nostrdb.c @@ -7739,6 +7739,16 @@ int ndb_builder_push_tag_str(struct ndb_builder *builder, return ndb_builder_finalize_tag(builder, pstr); } +/// Push an id element to the current tag. Needs to be 32 bytes +int ndb_builder_push_tag_id(struct ndb_builder *builder, + unsigned char *id) +{ + union ndb_packed_str pstr; + if (!ndb_builder_push_packed_id(builder, id, &pstr)) + return 0; + return ndb_builder_finalize_tag(builder, pstr); +} + // // CONFIG // diff --git a/nostrdb/src/nostrdb.h b/nostrdb/src/nostrdb.h index a25e8d43..c25c0fe6 100644 --- a/nostrdb/src/nostrdb.h +++ b/nostrdb/src/nostrdb.h @@ -551,6 +551,7 @@ void ndb_builder_set_id(struct ndb_builder *builder, unsigned char *id); void ndb_builder_set_kind(struct ndb_builder *builder, uint32_t kind); int ndb_builder_new_tag(struct ndb_builder *builder); int ndb_builder_push_tag_str(struct ndb_builder *builder, const char *str, int len); +int ndb_builder_push_tag_id(struct ndb_builder *builder, unsigned char *id); // FILTERS int ndb_filter_init(struct ndb_filter *);