From 168285b4569f862443419a2bffe221e1a8ab8150 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Sat, 24 Oct 2026 02:04:33 +0200 Subject: Replace all manual hex conversion with the new helper --- ot_fullscrape.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'ot_fullscrape.c') diff --git a/ot_fullscrape.c b/ot_fullscrape.c index 3e36e8e..08970a6 100644 --- a/ot_fullscrape.c +++ b/ot_fullscrape.c @@ -23,6 +23,7 @@ #include "textcode.h" /* Opentracker */ +#include "ot_hex.h" #include "ot_fullscrape.h" #include "ot_iovec.h" #include "ot_mutex.h" @@ -48,18 +49,6 @@ static void fullscrape_make_zstd(int taskid, ot_tasktype mode); /* Converter function from memory to human readable hex strings XXX - Duplicated from ot_stats. Needs fix. */ -static char *to_hex(char *d, uint8_t *s) { - char *m = "0123456789ABCDEF"; - char *t = d; - char *e = d + 40; - while (d < e) { - *d++ = m[*s >> 4]; - *d++ = m[*s++ & 15]; - } - *d = 0; - return t; -} - /* This is the entry point into this worker thread It grabs tasks from mutex_tasklist and delivers results back */ @@ -117,12 +106,12 @@ static char * fullscrape_write_one( ot_tasktype mode, char *r, ot_torrent *torre break; case TASK_FULLSCRAPE_TPB_ASCII: - to_hex(r, *hash); + hex_fromhash(r, *hash); r += 2 * sizeof(ot_hash); r += sprintf(r, ":%zd:%zd\n", seed_count, peer_count - seed_count); break; case TASK_FULLSCRAPE_TPB_ASCII_PLUS: - to_hex(r, *hash); + hex_fromhash(r, *hash); r += 2 * sizeof(ot_hash); r += sprintf(r, ":%zd:%zd:%zd\n", seed_count, peer_count - seed_count, down_count); break; @@ -138,7 +127,7 @@ static char * fullscrape_write_one( ot_tasktype mode, char *r, ot_torrent *torre r += sprintf(r, ":%zd:%zd\n", seed_count, peer_count - seed_count); break; case TASK_FULLSCRAPE_TRACKERSTATE: - to_hex(r, *hash); + hex_fromhash(r, *hash); r += 2 * sizeof(ot_hash); r += sprintf(r, ":%zd:%zd\n", torrent->peer_list6->base, down_count); break; -- cgit v1.3