diff --git a/caching/Dockerfile.alpine-musl b/caching/Dockerfile.alpine-musl index b9125e1..62142a7 100644 --- a/caching/Dockerfile.alpine-musl +++ b/caching/Dockerfile.alpine-musl @@ -25,6 +25,7 @@ RUN apk add --no-cache \ curl-dev \ curl-static \ sqlite-dev \ + postgresql-dev \ linux-headers \ wget \ bash @@ -103,13 +104,15 @@ RUN if [ "$DEBUG_BUILD" = "true" ]; then \ -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 \ -I. -Isrc -Inostr_core_lib -Inostr_core_lib/nostr_core \ -Inostr_core_lib/cjson -Inostr_core_lib/nostr_websocket \ + -I/usr/include/postgresql \ src/main.c src/debug.c src/jsonc_strip.c src/config.c src/state.c \ src/follow_graph.c src/relay_sink.c src/live_subscriber.c \ src/backfill.c src/relay_discovery.c \ + src/pg_inbox.c src/pg_config.c src/forward_catchup.c \ -o /build/caching_relay_static \ nostr_core_lib/libnostr_core.a \ -lwebsockets -lssl -lcrypto -lsecp256k1 \ - -lcurl -lz -lpthread -lm -ldl && \ + -lcurl -lz -lpthread -lm -ldl -lpq -lpgcommon -lpgport && \ eval "$STRIP_CMD" # Verify it's truly static diff --git a/caching/src/follow_graph.c b/caching/src/follow_graph.c index 3544065..2042215 100644 --- a/caching/src/follow_graph.c +++ b/caching/src/follow_graph.c @@ -7,6 +7,7 @@ #include #include +#include int cr_follow_is_root(const cr_config_t *cfg, const char *hex) { if (!cfg->root_hex_ready) return 0; @@ -16,17 +17,35 @@ int cr_follow_is_root(const cr_config_t *cfg, const char *hex) { return 0; } +/* Check if a string is a 64-character hex pubkey (no npub prefix). */ +static int is_hex_pubkey(const char *s) { + if (!s || strlen(s) != 64) return 0; + for (int i = 0; i < 64; i++) { + if (!isxdigit((unsigned char)s[i])) return 0; + } + return 1; +} + int cr_follow_decode_roots(cr_config_t *cfg) { for (int i = 0; i < cfg->root_npub_count; i++) { - unsigned char pubkey[32]; - if (nostr_decode_npub(cfg->root_npubs[i], pubkey) != NOSTR_SUCCESS) { - DEBUG_ERROR("follow: failed to decode npub '%s'", cfg->root_npubs[i]); - return -1; + const char *input = cfg->root_npubs[i]; + if (is_hex_pubkey(input)) { + /* Already a 64-char hex pubkey — copy directly. */ + strncpy(cfg->root_hex[i], input, 64); + cfg->root_hex[i][64] = '\0'; + } else { + /* Assume npub (bech32) format — decode to hex. */ + unsigned char pubkey[32]; + if (nostr_decode_npub(input, pubkey) != NOSTR_SUCCESS) { + DEBUG_ERROR("follow: failed to decode root pubkey '%s' " + "(not a valid npub or 64-char hex)", input); + return -1; + } + nostr_bytes_to_hex(pubkey, 32, cfg->root_hex[i]); } - nostr_bytes_to_hex(pubkey, 32, cfg->root_hex[i]); } cfg->root_hex_ready = 1; - DEBUG_INFO("follow: decoded %d root npubs", cfg->root_npub_count); + DEBUG_INFO("follow: decoded %d root pubkeys", cfg->root_npub_count); return 0; } diff --git a/src/main.h b/src/main.h index d243fc0..fcbb24f 100644 --- a/src/main.h +++ b/src/main.h @@ -13,8 +13,8 @@ // Using CRELAY_ prefix to avoid conflicts with nostr_core_lib VERSION macros #define CRELAY_VERSION_MAJOR 2 #define CRELAY_VERSION_MINOR 1 -#define CRELAY_VERSION_PATCH 25 -#define CRELAY_VERSION "v2.1.25" +#define CRELAY_VERSION_PATCH 26 +#define CRELAY_VERSION "v2.1.26" // Relay metadata (authoritative source for NIP-11 information) #define RELAY_NAME "C-Relay-PG"