cleanup: remove unused field last_seen from Onion_Friend

This commit is contained in:
zugz (tox) 2022-04-17 00:00:01 +00:00 committed by iphydf
parent 2824aa2544
commit 452a02f729
No known key found for this signature in database
GPG Key ID: 3855DBA2D74403C9
3 changed files with 13 additions and 24 deletions

View File

@ -1 +1 @@
4302ebfb454cfd087a919ac41ea513e04a9cdddfd9518c9c1959058bc244c06f /usr/local/bin/tox-bootstrapd
261754f9fc58cd2d229488f00ea3503afbcc797cebcd10af1fad9e1adb3faf46 /usr/local/bin/tox-bootstrapd

View File

@ -71,7 +71,6 @@ typedef struct Onion_Friend {
uint64_t last_noreplay;
uint64_t last_seen;
uint64_t last_populated; // the last time we had a fully populated client nodes list
uint64_t time_last_pinged; // the last time we pinged this friend with any node
@ -718,10 +717,6 @@ static int client_add_to_list(Onion_Client *onion_c, uint32_t num, const uint8_t
return -1;
}
if (is_stored == 1) {
onion_c->friends_list[num - 1].last_seen = mono_time_get(onion_c->mono_time);
}
node_list = onion_c->friends_list[num - 1].clients_list;
reference_id = onion_c->friends_list[num - 1].real_public_key;
list_length = MAX_ONION_CLIENTS;
@ -1003,7 +998,6 @@ static int handle_dhtpk_announce(void *object, const uint8_t *source_pubkey, con
}
onion_set_friend_DHT_pubkey(onion_c, friend_num, data + 1 + sizeof(uint64_t));
onion_c->friends_list[friend_num].last_seen = mono_time_get(onion_c->mono_time);
const uint16_t len_nodes = length - DHTPK_DATA_MIN_LENGTH;
@ -1391,7 +1385,7 @@ int onion_delfriend(Onion_Client *onion_c, int friend_num)
}
/** @brief Set the function for this friend that will be callbacked with object and number
* when that friends gives us one of the TCP relays he is connected to.
* when that friend gives us one of the TCP relays they are connected to.
*
* object and number will be passed as argument to this function.
*
@ -1412,7 +1406,7 @@ int recv_tcp_relay_handler(Onion_Client *onion_c, int friend_num,
}
/** @brief Set the function for this friend that will be callbacked with object and number
* when that friend gives us his DHT temporary public key.
* when that friend gives us their DHT temporary public key.
*
* object and number will be passed as argument to this function.
*
@ -1453,7 +1447,6 @@ int onion_set_friend_DHT_pubkey(Onion_Client *onion_c, int friend_num, const uin
}
}
onion_c->friends_list[friend_num].last_seen = mono_time_get(onion_c->mono_time);
onion_c->friends_list[friend_num].know_dht_public_key = true;
memcpy(onion_c->friends_list[friend_num].dht_public_key, dht_key, CRYPTO_PUBLIC_KEY_SIZE);
@ -1487,7 +1480,7 @@ unsigned int onion_getfriend_DHT_pubkey(const Onion_Client *onion_c, int friend_
*
* @retval -1 if public_key does NOT refer to a friend
* @retval 0 if public_key refers to a friend and we failed to find the friend (yet)
* @retval 1 if public_key refers to a friend and we found him
* @retval 1 if public_key refers to a friend and we found them
*/
int onion_getfriendip(const Onion_Client *onion_c, int friend_num, IP_Port *ip_port)
{
@ -1502,7 +1495,9 @@ int onion_getfriendip(const Onion_Client *onion_c, int friend_num, IP_Port *ip_p
/** @brief Set if friend is online or not.
* NOTE: This function is there and should be used so that we don't send useless packets to the friend if he is online.
*
* NOTE: This function is there and should be used so that we don't send
* useless packets to the friend if they are online.
*
* return -1 on failure.
* return 0 on success.
@ -1513,10 +1508,6 @@ int onion_set_friend_online(Onion_Client *onion_c, int friend_num, bool is_onlin
return -1;
}
if (!is_online && onion_c->friends_list[friend_num].is_online) {
onion_c->friends_list[friend_num].last_seen = mono_time_get(onion_c->mono_time);
}
onion_c->friends_list[friend_num].is_online = is_online;
/* This should prevent some clock related issues */
@ -1573,10 +1564,6 @@ static void do_friend(Onion_Client *onion_c, uint16_t friendnum)
const bool friend_is_new = o_friend->run_count <= ANNOUNCE_FRIEND_RUN_COUNT_BEGINNING;
if (!friend_is_new) {
if (o_friend->last_seen == 0) {
o_friend->last_seen = tm;
}
// how often we ping a node for a friend depends on how many times we've already tried.
// the interval increases exponentially, as the longer a friend has been offline, the less
// likely the case is that they're online and failed to find us

View File

@ -110,7 +110,9 @@ non_null()
int onion_delfriend(Onion_Client *onion_c, int friend_num);
/** @brief Set if friend is online or not.
* NOTE: This function is there and should be used so that we don't send useless packets to the friend if he is online.
*
* NOTE: This function is there and should be used so that we don't send
* useless packets to the friend if they are online.
*
* return -1 on failure.
* return 0 on success.
@ -122,7 +124,7 @@ int onion_set_friend_online(Onion_Client *onion_c, int friend_num, bool is_onlin
*
* @retval -1 if public_key does NOT refer to a friend
* @retval 0 if public_key refers to a friend and we failed to find the friend (yet)
* @retval 1 if public_key refers to a friend and we found him
* @retval 1 if public_key refers to a friend and we found them
*/
non_null()
int onion_getfriendip(const Onion_Client *onion_c, int friend_num, IP_Port *ip_port);
@ -130,7 +132,7 @@ int onion_getfriendip(const Onion_Client *onion_c, int friend_num, IP_Port *ip_p
typedef int recv_tcp_relay_cb(void *object, uint32_t number, const IP_Port *ip_port, const uint8_t *public_key);
/** @brief Set the function for this friend that will be callbacked with object and number
* when that friends gives us one of the TCP relays he is connected to.
* when that friend gives us one of the TCP relays they are connected to.
*
* object and number will be passed as argument to this function.
*
@ -144,7 +146,7 @@ int recv_tcp_relay_handler(Onion_Client *onion_c, int friend_num,
typedef void onion_dht_pk_cb(void *data, int32_t number, const uint8_t *dht_public_key, void *userdata);
/** @brief Set the function for this friend that will be callbacked with object and number
* when that friend gives us his DHT temporary public key.
* when that friend gives us their DHT temporary public key.
*
* object and number will be passed as argument to this function.
*