From 8efba55c86e0437ae65e0b0f5ab7271956265a8d Mon Sep 17 00:00:00 2001 From: Anton Date: Fri, 15 Mar 2019 19:37:08 +0400 Subject: pica-node: implement cleaning inactive nodes --- PICA_node.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'PICA_node.c') diff --git a/PICA_node.c b/PICA_node.c index a8810d4..574aa9b 100644 --- a/PICA_node.c +++ b/PICA_node.c @@ -2592,7 +2592,19 @@ int process_timeouts() if (time(0) - skynet_refresh_tmst > SKYNET_REFRESH_TIMEOUT && !nodewait_list) { + int clean_treshold = 100 - nodelink_list_count - cclink_list_count; + + if (clean_treshold <= 0) + clean_treshold = 3; + PICA_debug3("refreshing nodelist database"); + + if (nodelink_list_count > 0) + { + PICA_debug3("trying to clean nodes unreachable after more than %i attempts", clean_treshold); + PICA_nodeaddr_cleanold(nodecfg.nodes_db_file, clean_treshold); + } + PICA_node_joinskynet(nodecfg.nodes_db_file, nodecfg.announced_addr); } return 1; -- cgit v1.2.1