summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJesper Jensen <jesper@jnsn.dev>2025-05-07 23:01:47 +0200
committerJesper Jensen <jesper@jnsn.dev>2025-05-07 23:01:47 +0200
commitd230c01c0609529332eb72ae1b65f0ddddd515a0 (patch)
tree446a0f79335da46150f1e82ab3080bf5e8ed94fc /src
parentddc816a34861a0e090ea84fc945842593c34f45a (diff)
Transfer the id after loading it
Diffstat (limited to 'src')
-rw-r--r--src/main.c1
-rw-r--r--src/routing.c5
-rw-r--r--src/routing.h1
3 files changed, 7 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
index f984763..11e39bd 100644
--- a/src/main.c
+++ b/src/main.c
@@ -156,6 +156,7 @@ int main(int argc, char** argv) {
routing_init(&myID);
allocate_hashtable();
} else {
+ routing_setid(&myID);
routing_reset_expire(time(NULL) + PROTO_UNCTM);
}
diff --git a/src/routing.c b/src/routing.c
index a3e0b26..02b2f03 100644
--- a/src/routing.c
+++ b/src/routing.c
@@ -58,6 +58,11 @@ void routing_init(struct nodeid* myid) {
routing_flush();
}
+void routing_setid(struct nodeid *id) {
+ pTable->myID = *id;
+ myID = pTable->myID;
+}
+
void routing_update_metrics() {
char buf[4]; // Largest value is 157 + \0
diff --git a/src/routing.h b/src/routing.h
index aee2c8e..2d53b80 100644
--- a/src/routing.h
+++ b/src/routing.h
@@ -37,6 +37,7 @@ extern struct entry *table;
extern int table_size;
void routing_init(struct nodeid* myid);
+void routing_setid(struct nodeid *id);
void routing_update_metrics();
void routing_flush();
bool routing_interested(struct nodeid* id);