nostrdb.h (18396B)
1 #ifndef NOSTRDB_H 2 #define NOSTRDB_H 3 4 #include <inttypes.h> 5 #include "win.h" 6 #include "cursor.h" 7 8 // maximum number of filters allowed in a filter group 9 #define NDB_PACKED_STR 0x1 10 #define NDB_PACKED_ID 0x2 11 12 #define NDB_FLAG_NOMIGRATE (1 << 0) 13 #define NDB_FLAG_SKIP_NOTE_VERIFY (1 << 1) 14 #define NDB_FLAG_NO_FULLTEXT (1 << 2) 15 #define NDB_FLAG_NO_NOTE_BLOCKS (1 << 3) 16 #define NDB_FLAG_NO_STATS (1 << 4) 17 18 //#define DEBUG 1 19 20 #ifdef NDB_LOG 21 #define ndb_debug(...) printf(__VA_ARGS__) 22 #else 23 #define ndb_debug(...) (void)0 24 #endif 25 26 #include "str_block.h" 27 28 struct ndb_json_parser; 29 struct ndb; 30 struct ndb_blocks; 31 struct ndb_block; 32 struct ndb_note; 33 struct ndb_tag; 34 struct ndb_tags; 35 struct ndb_lmdb; 36 union ndb_packed_str; 37 struct bolt11; 38 39 // some bindings like swift needs help with forward declared pointers 40 struct ndb_tag_ptr { struct ndb_tag *ptr; }; 41 struct ndb_tags_ptr { struct ndb_tags *ptr; }; 42 struct ndb_block_ptr { struct ndb_block *ptr; }; 43 struct ndb_blocks_ptr { struct ndb_blocks *ptr; }; 44 struct ndb_note_ptr { struct ndb_note *ptr; }; 45 46 struct ndb_t { 47 struct ndb *ndb; 48 }; 49 50 struct ndb_str { 51 unsigned char flag; 52 union { 53 const char *str; 54 unsigned char *id; 55 }; 56 }; 57 58 struct ndb_keypair { 59 unsigned char pubkey[32]; 60 unsigned char secret[32]; 61 62 // this corresponds to secp256k1's keypair type. it's guaranteed to 63 // be 96 bytes according to their docs. I don't want to depend on 64 // the secp256k1 header here so we just use raw bytes. 65 unsigned char pair[96]; 66 }; 67 68 // function pointer for controlling what to do after we parse an id 69 typedef enum ndb_idres (*ndb_id_fn)(void *, const char *); 70 71 // callback function for when we receive new subscription results 72 typedef void (*ndb_sub_fn)(void *, uint64_t subid); 73 74 // id callback + closure data 75 struct ndb_id_cb { 76 ndb_id_fn fn; 77 void *data; 78 }; 79 80 // required to keep a read 81 struct ndb_txn { 82 struct ndb_lmdb *lmdb; 83 void *mdb_txn; 84 }; 85 86 struct ndb_event { 87 struct ndb_note *note; 88 }; 89 90 struct ndb_command_result { 91 int ok; 92 const char *msg; 93 int msglen; 94 }; 95 96 // From-client event types 97 enum fce_type { 98 NDB_FCE_EVENT = 0x1 99 }; 100 101 // To-client event types 102 enum tce_type { 103 NDB_TCE_EVENT = 0x1, 104 NDB_TCE_OK = 0x2, 105 NDB_TCE_NOTICE = 0x3, 106 NDB_TCE_EOSE = 0x4, 107 NDB_TCE_AUTH = 0x5, 108 }; 109 110 enum ndb_ingest_filter_action { 111 NDB_INGEST_REJECT, 112 NDB_INGEST_ACCEPT, 113 NDB_INGEST_SKIP_VALIDATION 114 }; 115 116 struct ndb_search_key 117 { 118 char search[24]; 119 unsigned char id[32]; 120 uint64_t timestamp; 121 }; 122 123 struct ndb_search { 124 struct ndb_search_key *key; 125 uint64_t profile_key; 126 void *cursor; // MDB_cursor * 127 }; 128 129 // From-client event 130 struct ndb_fce { 131 enum fce_type evtype; 132 union { 133 struct ndb_event event; 134 }; 135 }; 136 137 // To-client event 138 struct ndb_tce { 139 enum tce_type evtype; 140 const char *subid; 141 int subid_len; 142 143 union { 144 struct ndb_event event; 145 struct ndb_command_result command_result; 146 }; 147 }; 148 149 typedef enum ndb_ingest_filter_action (*ndb_ingest_filter_fn)(void *, struct ndb_note *); 150 151 enum ndb_filter_fieldtype { 152 NDB_FILTER_IDS = 1, 153 NDB_FILTER_AUTHORS = 2, 154 NDB_FILTER_KINDS = 3, 155 NDB_FILTER_TAGS = 4, 156 NDB_FILTER_SINCE = 5, 157 NDB_FILTER_UNTIL = 6, 158 NDB_FILTER_LIMIT = 7, 159 NDB_FILTER_SEARCH = 8, 160 }; 161 #define NDB_NUM_FILTERS 7 162 163 // when matching generic tags, we need to know if we're dealing with 164 // a pointer to a 32-byte ID or a null terminated string 165 enum ndb_generic_element_type { 166 NDB_ELEMENT_UNKNOWN = 0, 167 NDB_ELEMENT_STRING = 1, 168 NDB_ELEMENT_ID = 2, 169 NDB_ELEMENT_INT = 3, 170 }; 171 172 enum ndb_search_order { 173 NDB_ORDER_DESCENDING, 174 NDB_ORDER_ASCENDING, 175 }; 176 177 enum ndb_dbs { 178 NDB_DB_NOTE, 179 NDB_DB_META, 180 NDB_DB_PROFILE, 181 NDB_DB_NOTE_ID, 182 NDB_DB_PROFILE_PK, // profile pk index 183 NDB_DB_NDB_META, 184 NDB_DB_PROFILE_SEARCH, 185 NDB_DB_PROFILE_LAST_FETCH, 186 NDB_DB_NOTE_KIND, // note kind index 187 NDB_DB_NOTE_TEXT, // note fulltext index 188 NDB_DB_NOTE_BLOCKS, // parsed note blocks for rendering 189 NDB_DB_NOTE_TAGS, // note tags index 190 NDB_DB_NOTE_PUBKEY, // note pubkey index 191 NDB_DB_NOTE_PUBKEY_KIND, // note pubkey kind index 192 NDB_DBS, 193 }; 194 195 // common kinds. we collect stats on these in ndb_stat. mainly because I don't 196 // want to deal with including a hashtable to the project. 197 enum ndb_common_kind { 198 NDB_CKIND_PROFILE, 199 NDB_CKIND_TEXT, 200 NDB_CKIND_CONTACTS, 201 NDB_CKIND_DM, 202 NDB_CKIND_DELETE, 203 NDB_CKIND_REPOST, 204 NDB_CKIND_REACTION, 205 NDB_CKIND_ZAP, 206 NDB_CKIND_ZAP_REQUEST, 207 NDB_CKIND_NWC_REQUEST, 208 NDB_CKIND_NWC_RESPONSE, 209 NDB_CKIND_HTTP_AUTH, 210 NDB_CKIND_LIST, 211 NDB_CKIND_LONGFORM, 212 NDB_CKIND_STATUS, 213 NDB_CKIND_COUNT, // should always be last 214 }; 215 216 struct ndb_builder { 217 struct cursor mem; 218 struct cursor note_cur; 219 struct cursor strings; 220 struct cursor str_indices; 221 struct ndb_note *note; 222 struct ndb_tag *current_tag; 223 }; 224 225 struct ndb_iterator { 226 struct ndb_note *note; 227 struct ndb_tag *tag; 228 229 // current outer index 230 int index; 231 }; 232 233 struct ndb_filter_string { 234 const char *string; 235 int len; 236 }; 237 238 union ndb_filter_element { 239 struct ndb_filter_string string; 240 const unsigned char *id; 241 uint64_t integer; 242 }; 243 244 struct ndb_filter_field { 245 enum ndb_filter_fieldtype type; 246 enum ndb_generic_element_type elem_type; 247 char tag; // for generic queries like #t 248 }; 249 250 struct ndb_filter_elements { 251 struct ndb_filter_field field; 252 int count; 253 254 // this needs to be pointer size for reasons 255 // FIXME: what about on 32bit systems?? 256 uint64_t elements[0]; 257 }; 258 259 struct ndb_filter { 260 struct cursor elem_buf; 261 struct cursor data_buf; 262 int num_elements; 263 int finalized; 264 int current; 265 266 // struct ndb_filter_elements offsets into elem_buf 267 // 268 // TODO(jb55): this should probably be called fields. elements are 269 // the things within fields 270 int elements[NDB_NUM_FILTERS]; 271 }; 272 273 struct ndb_config { 274 int flags; 275 int ingester_threads; 276 size_t mapsize; 277 void *filter_context; 278 ndb_ingest_filter_fn ingest_filter; 279 void *sub_cb_ctx; 280 ndb_sub_fn sub_cb; 281 }; 282 283 struct ndb_text_search_config { 284 enum ndb_search_order order; 285 int limit; 286 }; 287 288 struct ndb_stat_counts { 289 size_t key_size; 290 size_t value_size; 291 size_t count; 292 }; 293 294 struct ndb_stat { 295 struct ndb_stat_counts dbs[NDB_DBS]; 296 struct ndb_stat_counts common_kinds[NDB_CKIND_COUNT]; 297 struct ndb_stat_counts other_kinds; 298 }; 299 300 #define MAX_TEXT_SEARCH_RESULTS 128 301 #define MAX_TEXT_SEARCH_WORDS 8 302 303 // unpacked form of the actual lmdb fulltext search key 304 // see `ndb_make_text_search_key` for how the packed version is constructed 305 struct ndb_text_search_key 306 { 307 int str_len; 308 const char *str; 309 uint64_t timestamp; 310 uint64_t note_id; 311 uint64_t word_index; 312 }; 313 314 struct ndb_text_search_result { 315 struct ndb_text_search_key key; 316 int prefix_chars; 317 318 // This is only set if we passed a filter for nip50 searches 319 struct ndb_note *note; 320 uint64_t note_size; 321 }; 322 323 struct ndb_text_search_results { 324 struct ndb_text_search_result results[MAX_TEXT_SEARCH_RESULTS]; 325 int num_results; 326 }; 327 328 enum ndb_block_type { 329 BLOCK_HASHTAG = 1, 330 BLOCK_TEXT = 2, 331 BLOCK_MENTION_INDEX = 3, 332 BLOCK_MENTION_BECH32 = 4, 333 BLOCK_URL = 5, 334 BLOCK_INVOICE = 6, 335 }; 336 #define NDB_NUM_BLOCK_TYPES 6 337 #define NDB_MAX_RELAYS 24 338 339 struct ndb_relays { 340 struct ndb_str_block relays[NDB_MAX_RELAYS]; 341 int num_relays; 342 }; 343 344 enum nostr_bech32_type { 345 NOSTR_BECH32_NOTE = 1, 346 NOSTR_BECH32_NPUB = 2, 347 NOSTR_BECH32_NPROFILE = 3, 348 NOSTR_BECH32_NEVENT = 4, 349 NOSTR_BECH32_NRELAY = 5, 350 NOSTR_BECH32_NADDR = 6, 351 NOSTR_BECH32_NSEC = 7, 352 }; 353 #define NOSTR_BECH32_KNOWN_TYPES 7 354 355 struct bech32_note { 356 const unsigned char *event_id; 357 }; 358 359 struct bech32_npub { 360 const unsigned char *pubkey; 361 }; 362 363 struct bech32_nsec { 364 const unsigned char *nsec; 365 }; 366 367 struct bech32_nevent { 368 struct ndb_relays relays; 369 const unsigned char *event_id; 370 const unsigned char *pubkey; // optional 371 uint32_t kind; 372 bool has_kind; 373 }; 374 375 struct bech32_nprofile { 376 struct ndb_relays relays; 377 const unsigned char *pubkey; 378 uint32_t kind; 379 bool has_kind; 380 }; 381 382 struct bech32_naddr { 383 struct ndb_relays relays; 384 struct ndb_str_block identifier; 385 const unsigned char *pubkey; 386 uint32_t kind; 387 }; 388 389 struct bech32_nrelay { 390 struct ndb_str_block relay; 391 }; 392 393 typedef struct nostr_bech32 { 394 enum nostr_bech32_type type; 395 396 union { 397 struct bech32_note note; 398 struct bech32_npub npub; 399 struct bech32_nsec nsec; 400 struct bech32_nevent nevent; 401 struct bech32_nprofile nprofile; 402 struct bech32_naddr naddr; 403 struct bech32_nrelay nrelay; 404 }; 405 } nostr_bech32_t; 406 407 408 struct ndb_mention_bech32_block { 409 struct ndb_str_block str; 410 struct nostr_bech32 bech32; 411 }; 412 413 struct ndb_invoice { 414 unsigned char version; 415 uint64_t amount; 416 uint64_t timestamp; 417 uint64_t expiry; 418 char *description; 419 unsigned char *description_hash; 420 }; 421 422 struct ndb_invoice_block { 423 struct ndb_str_block invstr; 424 struct ndb_invoice invoice; 425 }; 426 427 struct ndb_block { 428 enum ndb_block_type type; 429 union { 430 struct ndb_str_block str; 431 struct ndb_invoice_block invoice; 432 struct ndb_mention_bech32_block mention_bech32; 433 uint32_t mention_index; 434 } block; 435 }; 436 437 struct ndb_block_iterator { 438 const char *content; 439 struct ndb_blocks *blocks; 440 struct ndb_block block; 441 unsigned char *p; 442 }; 443 444 struct ndb_query_result { 445 struct ndb_note *note; 446 uint64_t note_size; 447 uint64_t note_id; 448 }; 449 450 struct ndb_query_results { 451 struct cursor cur; 452 }; 453 454 // CONFIG 455 void ndb_default_config(struct ndb_config *); 456 void ndb_config_set_ingest_threads(struct ndb_config *config, int threads); 457 void ndb_config_set_flags(struct ndb_config *config, int flags); 458 void ndb_config_set_mapsize(struct ndb_config *config, size_t mapsize); 459 void ndb_config_set_ingest_filter(struct ndb_config *config, ndb_ingest_filter_fn fn, void *); 460 void ndb_config_set_subscription_callback(struct ndb_config *config, ndb_sub_fn fn, void *ctx); 461 462 // HELPERS 463 int ndb_calculate_id(struct ndb_note *note, unsigned char *buf, int buflen); 464 int ndb_sign_id(struct ndb_keypair *keypair, unsigned char id[32], unsigned char sig[64]); 465 int ndb_create_keypair(struct ndb_keypair *key); 466 int ndb_decode_key(const char *secstr, struct ndb_keypair *keypair); 467 int ndb_note_verify(void *secp_ctx, unsigned char pubkey[32], unsigned char id[32], unsigned char signature[64]); 468 469 // NDB 470 int ndb_init(struct ndb **ndb, const char *dbdir, const struct ndb_config *); 471 int ndb_db_version(struct ndb_txn *txn); 472 int ndb_process_event(struct ndb *, const char *json, int len); 473 int ndb_process_events(struct ndb *, const char *ldjson, size_t len); 474 #ifndef _WIN32 475 // TODO: fix on windows 476 int ndb_process_events_stream(struct ndb *, FILE* fp); 477 #endif 478 int ndb_process_client_event(struct ndb *, const char *json, int len); 479 int ndb_process_client_events(struct ndb *, const char *json, size_t len); 480 int ndb_begin_query(struct ndb *, struct ndb_txn *); 481 int ndb_search_profile(struct ndb_txn *txn, struct ndb_search *search, const char *query); 482 int ndb_search_profile_next(struct ndb_search *search); 483 void ndb_search_profile_end(struct ndb_search *search); 484 int ndb_end_query(struct ndb_txn *); 485 int ndb_write_last_profile_fetch(struct ndb *ndb, const unsigned char *pubkey, uint64_t fetched_at); 486 uint64_t ndb_read_last_profile_fetch(struct ndb_txn *txn, const unsigned char *pubkey); 487 void *ndb_get_profile_by_pubkey(struct ndb_txn *txn, const unsigned char *pubkey, size_t *len, uint64_t *primkey); 488 void *ndb_get_profile_by_key(struct ndb_txn *txn, uint64_t key, size_t *len); 489 uint64_t ndb_get_notekey_by_id(struct ndb_txn *txn, const unsigned char *id); 490 uint64_t ndb_get_profilekey_by_pubkey(struct ndb_txn *txn, const unsigned char *id); 491 struct ndb_note *ndb_get_note_by_id(struct ndb_txn *txn, const unsigned char *id, size_t *len, uint64_t *primkey); 492 struct ndb_note *ndb_get_note_by_key(struct ndb_txn *txn, uint64_t key, size_t *len); 493 void *ndb_get_note_meta(struct ndb_txn *txn, const unsigned char *id, size_t *len); 494 void ndb_destroy(struct ndb *); 495 496 // BUILDER 497 int ndb_parse_json_note(struct ndb_json_parser *, struct ndb_note **); 498 int ndb_client_event_from_json(const char *json, int len, struct ndb_fce *fce, unsigned char *buf, int bufsize, struct ndb_id_cb *cb); 499 int ndb_ws_event_from_json(const char *json, int len, struct ndb_tce *tce, unsigned char *buf, int bufsize, struct ndb_id_cb *); 500 int ndb_note_from_json(const char *json, int len, struct ndb_note **, unsigned char *buf, int buflen); 501 int ndb_builder_init(struct ndb_builder *builder, unsigned char *buf, size_t bufsize); 502 int ndb_builder_finalize(struct ndb_builder *builder, struct ndb_note **note, struct ndb_keypair *privkey); 503 int ndb_builder_set_content(struct ndb_builder *builder, const char *content, int len); 504 void ndb_builder_set_created_at(struct ndb_builder *builder, uint64_t created_at); 505 void ndb_builder_set_sig(struct ndb_builder *builder, unsigned char *sig); 506 void ndb_builder_set_pubkey(struct ndb_builder *builder, unsigned char *pubkey); 507 void ndb_builder_set_id(struct ndb_builder *builder, unsigned char *id); 508 void ndb_builder_set_kind(struct ndb_builder *builder, uint32_t kind); 509 int ndb_builder_new_tag(struct ndb_builder *builder); 510 int ndb_builder_push_tag_str(struct ndb_builder *builder, const char *str, int len); 511 512 // FILTERS 513 int ndb_filter_init(struct ndb_filter *); 514 515 /// Allocate a filter with a fixed sized buffer (where pages is number of 4096-byte sized blocks) 516 /// You can set pages to 1 if you know you are constructing small filters 517 // TODO: replace this with passed-in buffers 518 int ndb_filter_init_with(struct ndb_filter *filter, int pages); 519 520 int ndb_filter_add_id_element(struct ndb_filter *, const unsigned char *id); 521 int ndb_filter_add_int_element(struct ndb_filter *, uint64_t integer); 522 int ndb_filter_add_str_element(struct ndb_filter *, const char *str); 523 int ndb_filter_eq(const struct ndb_filter *, const struct ndb_filter *); 524 525 /// is `a` a subset of `b` 526 int ndb_filter_is_subset_of(const struct ndb_filter *a, const struct ndb_filter *b); 527 528 // filters from json 529 int ndb_filter_from_json(const char *, int len, struct ndb_filter *filter, unsigned char *buf, int bufsize); 530 531 // getting field elements 532 unsigned char *ndb_filter_get_id_element(const struct ndb_filter *, const struct ndb_filter_elements *, int index); 533 const char *ndb_filter_get_string_element(const struct ndb_filter *, const struct ndb_filter_elements *, int index); 534 uint64_t ndb_filter_get_int_element(const struct ndb_filter_elements *, int index); 535 uint64_t *ndb_filter_get_int_element_ptr(struct ndb_filter_elements *, int index); 536 537 struct ndb_filter_elements *ndb_filter_current_element(const struct ndb_filter *); 538 struct ndb_filter_elements *ndb_filter_get_elements(const struct ndb_filter *, int); 539 int ndb_filter_start_field(struct ndb_filter *, enum ndb_filter_fieldtype); 540 int ndb_filter_start_tag_field(struct ndb_filter *, char tag); 541 int ndb_filter_matches(struct ndb_filter *, struct ndb_note *); 542 int ndb_filter_clone(struct ndb_filter *dst, struct ndb_filter *src); 543 int ndb_filter_end(struct ndb_filter *); 544 void ndb_filter_end_field(struct ndb_filter *); 545 void ndb_filter_destroy(struct ndb_filter *); 546 int ndb_filter_json(const struct ndb_filter *, char *buf, int buflen); 547 548 // SUBSCRIPTIONS 549 uint64_t ndb_subscribe(struct ndb *, struct ndb_filter *, int num_filters); 550 int ndb_wait_for_notes(struct ndb *, uint64_t subid, uint64_t *note_ids, int note_id_capacity); 551 int ndb_poll_for_notes(struct ndb *, uint64_t subid, uint64_t *note_ids, int note_id_capacity); 552 int ndb_unsubscribe(struct ndb *, uint64_t subid); 553 int ndb_num_subscriptions(struct ndb *); 554 555 // FULLTEXT SEARCH 556 int ndb_text_search(struct ndb_txn *txn, const char *query, struct ndb_text_search_results *, struct ndb_text_search_config *); 557 int ndb_text_search_with(struct ndb_txn *txn, const char *query, struct ndb_text_search_results *, struct ndb_text_search_config *, struct ndb_filter *filter); 558 void ndb_default_text_search_config(struct ndb_text_search_config *); 559 void ndb_text_search_config_set_order(struct ndb_text_search_config *, enum ndb_search_order); 560 void ndb_text_search_config_set_limit(struct ndb_text_search_config *, int limit); 561 562 // QUERY 563 int ndb_query(struct ndb_txn *txn, struct ndb_filter *filters, int num_filters, struct ndb_query_result *results, int result_capacity, int *count); 564 565 // STATS 566 int ndb_stat(struct ndb *ndb, struct ndb_stat *stat); 567 void ndb_stat_counts_init(struct ndb_stat_counts *counts); 568 569 // NOTE 570 const char *ndb_note_content(struct ndb_note *note); 571 struct ndb_str ndb_note_str(struct ndb_note *note, union ndb_packed_str *pstr); 572 uint32_t ndb_note_content_length(struct ndb_note *note); 573 uint32_t ndb_note_created_at(struct ndb_note *note); 574 uint32_t ndb_note_kind(struct ndb_note *note); 575 unsigned char *ndb_note_id(struct ndb_note *note); 576 unsigned char *ndb_note_pubkey(struct ndb_note *note); 577 unsigned char *ndb_note_sig(struct ndb_note *note); 578 void _ndb_note_set_kind(struct ndb_note *note, uint32_t kind); 579 struct ndb_tags *ndb_note_tags(struct ndb_note *note); 580 int ndb_str_len(struct ndb_str *str); 581 582 /// write the note as json to a buffer 583 int ndb_note_json(struct ndb_note *, char *buf, int buflen); 584 585 // TAGS 586 void ndb_tags_iterate_start(struct ndb_note *note, struct ndb_iterator *iter); 587 uint16_t ndb_tags_count(struct ndb_tags *); 588 uint16_t ndb_tag_count(struct ndb_tag *); 589 590 // ITER 591 int ndb_tags_iterate_next(struct ndb_iterator *iter); 592 struct ndb_str ndb_iter_tag_str(struct ndb_iterator *iter, int ind); 593 struct ndb_str ndb_tag_str(struct ndb_note *note, struct ndb_tag *tag, int ind); 594 595 // NAMES 596 const char *ndb_db_name(enum ndb_dbs db); 597 const char *ndb_kind_name(enum ndb_common_kind ck); 598 enum ndb_common_kind ndb_kind_to_common_kind(int kind); 599 600 // CONTENT PARSER 601 int ndb_parse_content(unsigned char *buf, int buf_size, 602 const char *content, int content_len, 603 struct ndb_blocks **blocks_p); 604 605 // BLOCKS 606 enum ndb_block_type ndb_get_block_type(struct ndb_block *block); 607 int ndb_blocks_flags(struct ndb_blocks *block); 608 size_t ndb_blocks_total_size(struct ndb_blocks *blocks); 609 int ndb_blocks_word_count(struct ndb_blocks *blocks); 610 611 /// Free blocks if they are owned, safe to call on unowned blocks as well. 612 void ndb_blocks_free(struct ndb_blocks *blocks); 613 614 // BLOCK DB 615 struct ndb_blocks *ndb_get_blocks_by_key(struct ndb *ndb, struct ndb_txn *txn, uint64_t note_key); 616 617 // BLOCK ITERATORS 618 void ndb_blocks_iterate_start(const char *, struct ndb_blocks *, struct ndb_block_iterator *); 619 struct ndb_block *ndb_blocks_iterate_next(struct ndb_block_iterator *); 620 621 // STR BLOCKS 622 struct ndb_str_block *ndb_block_str(struct ndb_block *); 623 const char *ndb_str_block_ptr(struct ndb_str_block *); 624 uint32_t ndb_str_block_len(struct ndb_str_block *); 625 626 // BECH32 BLOCKS 627 struct nostr_bech32 *ndb_bech32_block(struct ndb_block *block); 628 629 #endif