nostrdb: config: custom writer scratch size

making more things configurable if you have memory constraints

Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin
2025-03-19 12:57:53 -07:00
committed by Daniel D’Aquino
parent 3290e1f9d2
commit fcd8131063
2 changed files with 25 additions and 8 deletions

View File

@@ -273,6 +273,7 @@ struct ndb_filter {
struct ndb_config {
int flags;
int ingester_threads;
int writer_scratch_buffer_size;
size_t mapsize;
void *filter_context;
ndb_ingest_filter_fn ingest_filter;
@@ -459,6 +460,11 @@ void ndb_config_set_mapsize(struct ndb_config *config, size_t mapsize);
void ndb_config_set_ingest_filter(struct ndb_config *config, ndb_ingest_filter_fn fn, void *);
void ndb_config_set_subscription_callback(struct ndb_config *config, ndb_sub_fn fn, void *ctx);
/// Configurable scratch buffer size for the writer thread. Default is 2MB. If you have smaller notes
/// you can decrease this to reduce memory usage. If you have bigger notes you should increase this so
/// that the writer thread can properly parse larger notes.
void ndb_config_set_writer_scratch_buffer_size(struct ndb_config *config, int scratch_size);
// HELPERS
int ndb_calculate_id(struct ndb_note *note, unsigned char *buf, int buflen);
int ndb_sign_id(struct ndb_keypair *keypair, unsigned char id[32], unsigned char sig[64]);