nostrdb

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

print_util.h (756B)


      1 
      2 static void ndb_print_text_search_key(struct ndb_text_search_key *key)
      3 {
      4 	printf("K<'%.*s' %d %" PRIu64 " note_id:%" PRIu64 ">", key->str_len, key->str,
      5 						    key->word_index,
      6 						    key->timestamp,
      7 						    key->note_id);
      8 }
      9 
     10 static void print_hex(unsigned char* data, size_t size) {
     11 	size_t i;
     12 	for (i = 0; i < size; i++) {
     13 		printf("%02x", data[i]);
     14 	}
     15 }
     16 
     17 
     18 static void ndb_print_text_search_result(struct ndb_txn *txn,
     19 		struct ndb_text_search_result *r)
     20 {
     21 	size_t len;
     22 	struct ndb_note *note;
     23 
     24 	ndb_print_text_search_key(&r->key);
     25 
     26 	if (!(note = ndb_get_note_by_key(txn, r->key.note_id, &len))) {
     27 		printf(": note not found");
     28 		return;
     29 	}
     30 
     31 	printf(" ");
     32 	print_hex(ndb_note_id(note), 32);
     33 
     34 	printf("\n%s\n\n---\n", ndb_note_content(note));
     35 }
     36