@@ -1828,7 +1828,9 @@ static uint8_t do_ping_and_sendnode_requests(DHT *dht, uint64_t *lastgetnode, co
18281828 ++ not_kill ;
18291829
18301830 if (mono_time_is_timeout (dht -> mono_time , assoc -> last_pinged , PING_INTERVAL )) {
1831- dht_getnodes (dht , & assoc -> ip_port , client -> public_key , public_key );
1831+ const IP_Port * target = & assoc -> ip_port ;
1832+ const uint8_t * target_key = client -> public_key ;
1833+ dht_getnodes (dht , target , target_key , public_key );
18321834 assoc -> last_pinged = temp_time ;
18331835 }
18341836
@@ -1861,7 +1863,9 @@ static uint8_t do_ping_and_sendnode_requests(DHT *dht, uint64_t *lastgetnode, co
18611863 rand_node += random_range_u32 (dht -> rng , num_nodes - (rand_node + 1 ));
18621864 }
18631865
1864- dht_getnodes (dht , & assoc_list [rand_node ]-> ip_port , client_list [rand_node ]-> public_key , public_key );
1866+ const IP_Port * target = & assoc_list [rand_node ]-> ip_port ;
1867+ const uint8_t * target_key = client_list [rand_node ]-> public_key ;
1868+ dht_getnodes (dht , target , target_key , public_key );
18651869
18661870 * lastgetnode = temp_time ;
18671871 ++ * bootstrap_times ;
@@ -1890,8 +1894,7 @@ static void do_dht_friends(DHT *dht)
18901894 dht_friend -> num_to_bootstrap = 0 ;
18911895
18921896 do_ping_and_sendnode_requests (dht , & dht_friend -> lastgetnode , dht_friend -> public_key , dht_friend -> client_list ,
1893- MAX_FRIEND_CLIENTS ,
1894- & dht_friend -> bootstrap_times , true);
1897+ MAX_FRIEND_CLIENTS , & dht_friend -> bootstrap_times , true);
18951898 }
18961899}
18971900
@@ -2634,6 +2637,7 @@ DHT *new_dht(const Logger *log, const Memory *mem, const Random *rng, const Netw
26342637 DHT * const dht = (DHT * )mem_alloc (mem , sizeof (DHT ));
26352638
26362639 if (dht == nullptr ) {
2640+ LOGGER_ERROR (log , "failed to allocate DHT struct (%ld bytes)" , (unsigned long )sizeof (DHT ));
26372641 return nullptr ;
26382642 }
26392643
@@ -2651,6 +2655,7 @@ DHT *new_dht(const Logger *log, const Memory *mem, const Random *rng, const Netw
26512655 dht -> ping = ping_new (mem , mono_time , rng , dht );
26522656
26532657 if (dht -> ping == nullptr ) {
2658+ LOGGER_ERROR (log , "failed to initialise ping" );
26542659 kill_dht (dht );
26552660 return nullptr ;
26562661 }
@@ -2667,10 +2672,11 @@ DHT *new_dht(const Logger *log, const Memory *mem, const Random *rng, const Netw
26672672
26682673 crypto_new_keypair (rng , dht -> self_public_key , dht -> self_secret_key );
26692674
2670- dht -> shared_keys_recv = shared_key_cache_new (mono_time , mem , dht -> self_secret_key , KEYS_TIMEOUT , MAX_KEYS_PER_SLOT );
2671- dht -> shared_keys_sent = shared_key_cache_new (mono_time , mem , dht -> self_secret_key , KEYS_TIMEOUT , MAX_KEYS_PER_SLOT );
2675+ dht -> shared_keys_recv = shared_key_cache_new (log , mono_time , mem , dht -> self_secret_key , KEYS_TIMEOUT , MAX_KEYS_PER_SLOT );
2676+ dht -> shared_keys_sent = shared_key_cache_new (log , mono_time , mem , dht -> self_secret_key , KEYS_TIMEOUT , MAX_KEYS_PER_SLOT );
26722677
26732678 if (dht -> shared_keys_recv == nullptr || dht -> shared_keys_sent == nullptr ) {
2679+ LOGGER_ERROR (log , "failed to initialise shared key cache" );
26742680 kill_dht (dht );
26752681 return nullptr ;
26762682 }
@@ -2679,6 +2685,7 @@ DHT *new_dht(const Logger *log, const Memory *mem, const Random *rng, const Netw
26792685 dht -> dht_ping_array = ping_array_new (mem , DHT_PING_ARRAY_SIZE , PING_TIMEOUT );
26802686
26812687 if (dht -> dht_ping_array == nullptr ) {
2688+ LOGGER_ERROR (log , "failed to initialise ping array" );
26822689 kill_dht (dht );
26832690 return nullptr ;
26842691 }
@@ -2691,6 +2698,7 @@ DHT *new_dht(const Logger *log, const Memory *mem, const Random *rng, const Netw
26912698
26922699 uint32_t token ; // We don't intend to delete these ever, but need to pass the token
26932700 if (dht_addfriend (dht , random_public_key_bytes , nullptr , nullptr , 0 , & token ) != 0 ) {
2701+ LOGGER_ERROR (log , "failed to add initial random seed DHT friends" );
26942702 kill_dht (dht );
26952703 return nullptr ;
26962704 }
0 commit comments