From 89ef4c5c3bdc65862bffcffb7e9e21103d4e8bb4 Mon Sep 17 00:00:00 2001 From: Jesper Jensen Date: Sat, 10 May 2025 16:40:42 +0200 Subject: Run the lookup once in a while --- src/main.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 7118f66..43d24e8 100644 --- a/src/main.c +++ b/src/main.c @@ -178,7 +178,7 @@ int main(int argc, char** argv) { // Init the lookup dht.lookup.target = (struct nodeid){.inner={0x19b8a941, 0x38fa0191, 0x1403fac2, 0x581000ab, 0x19583cda}}; - dht.lookup.state = OP_EMPTY; // We want this to run at some point. + dht.lookup.state = OP_PENDING; // We want this to run at some point. #define RECV_BUFF_SIZE 4096 char buff_storage[RECV_BUFF_SIZE+1]; @@ -238,6 +238,12 @@ int main(int argc, char** argv) { rc = proto_run(&dht, buff, recv_len, (struct sockaddr_in*)&remote, remote_len, now, &message_cursor, outbuff+OUTBOX_SIZE); flush_messages(dht.sfd, outbuff, message_cursor); + if(dht.lookup.state == OP_COMPLETED && difftime(dht.lookup.timeout, now) < 0.0) { + dbg("Restart LOOKUP"); + // Restart the lookup periodically + dht.lookup.state = OP_PENDING; + } + save_config(); } -- cgit v1.2.3