mirror of
https://github.com/irungentoo/toxcore.git
synced 2024-03-22 13:30:51 +08:00
cleanup: Mark Mono_Time const where possible.
This commit is contained in:
parent
d56cb13279
commit
ad90f5bbb8
|
@ -26,9 +26,9 @@ static inline IP get_loopback(void)
|
||||||
#endif
|
#endif
|
||||||
return ip;
|
return ip;
|
||||||
}
|
}
|
||||||
static void do_onion(Onion *onion)
|
static void do_onion(Mono_Time *mono_time, Onion *onion)
|
||||||
{
|
{
|
||||||
mono_time_update(onion->mono_time);
|
mono_time_update(mono_time);
|
||||||
|
|
||||||
networking_poll(onion->net, nullptr);
|
networking_poll(onion->net, nullptr);
|
||||||
do_dht(onion->dht);
|
do_dht(onion->dht);
|
||||||
|
@ -229,16 +229,16 @@ static void test_basic(void)
|
||||||
handled_test_1 = 0;
|
handled_test_1 = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
do_onion(onion1);
|
do_onion(mono_time1, onion1);
|
||||||
do_onion(onion2);
|
do_onion(mono_time2, onion2);
|
||||||
} while (handled_test_1 == 0);
|
} while (handled_test_1 == 0);
|
||||||
|
|
||||||
networking_registerhandler(onion1->net, NET_PACKET_ANNOUNCE_RESPONSE_OLD, &handle_test_2, onion1);
|
networking_registerhandler(onion1->net, NET_PACKET_ANNOUNCE_RESPONSE_OLD, &handle_test_2, onion1);
|
||||||
handled_test_2 = 0;
|
handled_test_2 = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
do_onion(onion1);
|
do_onion(mono_time1, onion1);
|
||||||
do_onion(onion2);
|
do_onion(mono_time2, onion2);
|
||||||
} while (handled_test_2 == 0);
|
} while (handled_test_2 == 0);
|
||||||
|
|
||||||
Onion_Announce *onion1_a = new_onion_announce(log1, mono_time1, onion1->dht);
|
Onion_Announce *onion1_a = new_onion_announce(log1, mono_time1, onion1->dht);
|
||||||
|
@ -260,8 +260,8 @@ static void test_basic(void)
|
||||||
handled_test_3 = 0;
|
handled_test_3 = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
do_onion(onion1);
|
do_onion(mono_time1, onion1);
|
||||||
do_onion(onion2);
|
do_onion(mono_time2, onion2);
|
||||||
c_sleep(50);
|
c_sleep(50);
|
||||||
} while (handled_test_3 == 0);
|
} while (handled_test_3 == 0);
|
||||||
|
|
||||||
|
@ -278,8 +278,8 @@ static void test_basic(void)
|
||||||
dht_get_self_public_key(onion1->dht), s);
|
dht_get_self_public_key(onion1->dht), s);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
do_onion(onion1);
|
do_onion(mono_time1, onion1);
|
||||||
do_onion(onion2);
|
do_onion(mono_time2, onion2);
|
||||||
c_sleep(50);
|
c_sleep(50);
|
||||||
} while (memcmp(onion_announce_entry_public_key(onion2_a, ONION_ANNOUNCE_MAX_ENTRIES - 2),
|
} while (memcmp(onion_announce_entry_public_key(onion2_a, ONION_ANNOUNCE_MAX_ENTRIES - 2),
|
||||||
dht_get_self_public_key(onion1->dht),
|
dht_get_self_public_key(onion1->dht),
|
||||||
|
@ -303,8 +303,8 @@ static void test_basic(void)
|
||||||
handled_test_4 = 0;
|
handled_test_4 = 0;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
do_onion(onion1);
|
do_onion(mono_time1, onion1);
|
||||||
do_onion(onion2);
|
do_onion(mono_time2, onion2);
|
||||||
c_sleep(50);
|
c_sleep(50);
|
||||||
} while (handled_test_4 == 0);
|
} while (handled_test_4 == 0);
|
||||||
|
|
||||||
|
|
|
@ -641,7 +641,7 @@ void set_callback_handle_recv_1(Onion *onion, onion_recv_1_cb *function, void *o
|
||||||
onion->callback_object = object;
|
onion->callback_object = object;
|
||||||
}
|
}
|
||||||
|
|
||||||
Onion *new_onion(const Logger *log, Mono_Time *mono_time, DHT *dht)
|
Onion *new_onion(const Logger *log, const Mono_Time *mono_time, DHT *dht)
|
||||||
{
|
{
|
||||||
if (dht == nullptr) {
|
if (dht == nullptr) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -17,7 +17,7 @@ typedef int onion_recv_1_cb(void *object, const IP_Port *dest, const uint8_t *da
|
||||||
|
|
||||||
typedef struct Onion {
|
typedef struct Onion {
|
||||||
const Logger *log;
|
const Logger *log;
|
||||||
Mono_Time *mono_time;
|
const Mono_Time *mono_time;
|
||||||
DHT *dht;
|
DHT *dht;
|
||||||
Networking_Core *net;
|
Networking_Core *net;
|
||||||
uint8_t secret_symmetric_key[CRYPTO_SYMMETRIC_KEY_SIZE];
|
uint8_t secret_symmetric_key[CRYPTO_SYMMETRIC_KEY_SIZE];
|
||||||
|
@ -143,7 +143,7 @@ non_null(1) nullable(2, 3)
|
||||||
void set_callback_handle_recv_1(Onion *onion, onion_recv_1_cb *function, void *object);
|
void set_callback_handle_recv_1(Onion *onion, onion_recv_1_cb *function, void *object);
|
||||||
|
|
||||||
non_null()
|
non_null()
|
||||||
Onion *new_onion(const Logger *log, Mono_Time *mono_time, DHT *dht);
|
Onion *new_onion(const Logger *log, const Mono_Time *mono_time, DHT *dht);
|
||||||
|
|
||||||
non_null()
|
non_null()
|
||||||
void kill_onion(Onion *onion);
|
void kill_onion(Onion *onion);
|
||||||
|
|
|
@ -44,7 +44,7 @@ typedef struct Onion_Announce_Entry {
|
||||||
|
|
||||||
struct Onion_Announce {
|
struct Onion_Announce {
|
||||||
const Logger *log;
|
const Logger *log;
|
||||||
Mono_Time *mono_time;
|
const Mono_Time *mono_time;
|
||||||
DHT *dht;
|
DHT *dht;
|
||||||
Networking_Core *net;
|
Networking_Core *net;
|
||||||
Onion_Announce_Entry entries[ONION_ANNOUNCE_MAX_ENTRIES];
|
Onion_Announce_Entry entries[ONION_ANNOUNCE_MAX_ENTRIES];
|
||||||
|
@ -648,7 +648,7 @@ static int handle_data_request(void *object, const IP_Port *source, const uint8_
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Onion_Announce *new_onion_announce(const Logger *log, Mono_Time *mono_time, DHT *dht)
|
Onion_Announce *new_onion_announce(const Logger *log, const Mono_Time *mono_time, DHT *dht)
|
||||||
{
|
{
|
||||||
if (dht == nullptr) {
|
if (dht == nullptr) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -128,7 +128,7 @@ void onion_announce_extra_data_callback(Onion_Announce *onion_a, uint16_t extra_
|
||||||
pack_extra_data_cb *extra_data_callback, void *extra_data_object);
|
pack_extra_data_cb *extra_data_callback, void *extra_data_object);
|
||||||
|
|
||||||
non_null()
|
non_null()
|
||||||
Onion_Announce *new_onion_announce(const Logger *log, Mono_Time *mono_time, DHT *dht);
|
Onion_Announce *new_onion_announce(const Logger *log, const Mono_Time *mono_time, DHT *dht);
|
||||||
|
|
||||||
non_null()
|
non_null()
|
||||||
void kill_onion_announce(Onion_Announce *onion_a);
|
void kill_onion_announce(Onion_Announce *onion_a);
|
||||||
|
|
|
@ -98,7 +98,7 @@ typedef struct Onion_Data_Handler {
|
||||||
} Onion_Data_Handler;
|
} Onion_Data_Handler;
|
||||||
|
|
||||||
struct Onion_Client {
|
struct Onion_Client {
|
||||||
Mono_Time *mono_time;
|
const Mono_Time *mono_time;
|
||||||
const Logger *logger;
|
const Logger *logger;
|
||||||
|
|
||||||
DHT *dht;
|
DHT *dht;
|
||||||
|
@ -1920,7 +1920,7 @@ void do_onion_client(Onion_Client *onion_c)
|
||||||
onion_c->last_run = mono_time_get(onion_c->mono_time);
|
onion_c->last_run = mono_time_get(onion_c->mono_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
Onion_Client *new_onion_client(const Logger *logger, Mono_Time *mono_time, Net_Crypto *c)
|
Onion_Client *new_onion_client(const Logger *logger, const Mono_Time *mono_time, Net_Crypto *c)
|
||||||
{
|
{
|
||||||
if (c == nullptr) {
|
if (c == nullptr) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
|
@ -197,7 +197,7 @@ non_null()
|
||||||
void do_onion_client(Onion_Client *onion_c);
|
void do_onion_client(Onion_Client *onion_c);
|
||||||
|
|
||||||
non_null()
|
non_null()
|
||||||
Onion_Client *new_onion_client(const Logger *logger, Mono_Time *mono_time, Net_Crypto *c);
|
Onion_Client *new_onion_client(const Logger *logger, const Mono_Time *mono_time, Net_Crypto *c);
|
||||||
|
|
||||||
non_null()
|
non_null()
|
||||||
void kill_onion_client(Onion_Client *onion_c);
|
void kill_onion_client(Onion_Client *onion_c);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user