diff options
| author | Jesper Jensen <jesper@jnsn.dev> | 2025-05-10 16:40:42 +0200 |
|---|---|---|
| committer | Jesper Jensen <jesper@jnsn.dev> | 2025-05-10 16:40:42 +0200 |
| commit | 89ef4c5c3bdc65862bffcffb7e9e21103d4e8bb4 (patch) | |
| tree | 925515267f0634c5586c6f3cc1c5b496be56f856 /src/main.c | |
| parent | 84ac4433045ba3ccd389ce0d3a9e573c1da30f7c (diff) | |
Run the lookup once in a while
Diffstat (limited to 'src/main.c')
| -rw-r--r-- | src/main.c | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -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(); } |
