@@ -3383,15 +3383,11 @@ namespace tools
33833383 }
33843384 // ------------------------------------------------------------------------------------------------------------------------------
33853385
3386- #define get_current_UTC_time (current_date_and_time,current_UTC_date_and_time ) \
3387- time (¤t_date_and_time); \
3388- gmtime_r (¤t_date_and_time,¤t_UTC_date_and_time);
3389-
33903386void sync_minutes_and_seconds (const int SETTINGS)
33913387{
33923388 // Variables
3393- time_t current_date_and_time;
3394- struct tm current_UTC_date_and_time;
3389+ std:: time_t current_date_and_time;
3390+ std::tm* current_UTC_date_and_time;
33953391
33963392 std::cout << " Waiting until the next valid data interval, this will be less than 5 minutes" ;
33973393
@@ -3401,23 +3397,25 @@ void sync_minutes_and_seconds(const int SETTINGS)
34013397
34023398 do
34033399 {
3404- nanosleep ((const struct timespec []){{0 , 200000000L }}, NULL );
3405- get_current_UTC_time (current_date_and_time,current_UTC_date_and_time);
3406- } while (current_UTC_date_and_time.tm_min % BLOCK_TIME != 2 && current_UTC_date_and_time.tm_min % BLOCK_TIME != 3 );
3400+ std::this_thread::sleep_for (std::chrono::milliseconds (200 ));
3401+ current_date_and_time = std::time (0 );
3402+ current_UTC_date_and_time = std::gmtime (¤t_date_and_time);
3403+ } while (current_UTC_date_and_time->tm_min % BLOCK_TIME != 2 && current_UTC_date_and_time->tm_min % BLOCK_TIME != 3 );
34073404 }
34083405 else
34093406 {
34103407 std::cout << " Waiting until the next valid data interval, this will be at the beginning of the hour" ;
34113408
34123409 do
34133410 {
3414- nanosleep ((const struct timespec []){{0 , 200000000L }}, NULL );
3415- get_current_UTC_time (current_date_and_time,current_UTC_date_and_time);
3416- } while (current_UTC_date_and_time.tm_min != 2 );
3411+ std::this_thread::sleep_for (std::chrono::milliseconds (200 ));
3412+ current_date_and_time = std::time (0 );
3413+ current_UTC_date_and_time = std::gmtime (¤t_date_and_time);
3414+ } while (current_UTC_date_and_time->tm_min != 2 );
34173415 }
34183416
34193417 // wait a few more seconds due to not all clocks being synced at the same second
3420- sleep ( 3 );
3418+ std::this_thread::sleep_for ( std::chrono::milliseconds ( 3000 ) );
34213419 return ;
34223420}
34233421
@@ -3474,7 +3472,7 @@ bool wallet_rpc_server::on_vote(const wallet_rpc::COMMAND_RPC_VOTE::request& req
34743472 for (count = 0 ; string.find (" |" ) == std::string::npos && count < MAXIMUM_CONNECTION_TIMEOUT_SETTINGS; count++)
34753473 {
34763474 string = send_and_receive_data (network_data_nodes_list.network_data_nodes_IP_address [(int )(rand () % NETWORK_DATA_NODES_AMOUNT)],MESSAGE,SOCKET_CONNECTION_TIMEOUT_SETTINGS);
3477- sleep ( 1 );
3475+ std::this_thread::sleep_for ( std::chrono::milliseconds ( 1000 ) );
34783476 }
34793477
34803478 if (count == MAXIMUM_CONNECTION_TIMEOUT_SETTINGS)
@@ -3636,7 +3634,7 @@ bool wallet_rpc_server::on_delegate_register(const wallet_rpc::COMMAND_RPC_DELEG
36363634 for (count = 0 ; string.find (" |" ) == std::string::npos && count < MAXIMUM_CONNECTION_TIMEOUT_SETTINGS; count++)
36373635 {
36383636 string = send_and_receive_data (network_data_nodes_list.network_data_nodes_IP_address [(int )(rand () % NETWORK_DATA_NODES_AMOUNT)],MESSAGE,SOCKET_CONNECTION_TIMEOUT_SETTINGS);
3639- sleep ( 1 );
3637+ std::this_thread::sleep_for ( std::chrono::milliseconds ( 1000 ) );
36403638 }
36413639
36423640 if (count == MAXIMUM_CONNECTION_TIMEOUT_SETTINGS)
@@ -3828,7 +3826,7 @@ bool wallet_rpc_server::on_delegate_update(const wallet_rpc::COMMAND_RPC_DELEGAT
38283826 for (count = 0 ; string.find (" |" ) == std::string::npos && count < MAXIMUM_CONNECTION_TIMEOUT_SETTINGS; count++)
38293827 {
38303828 string = send_and_receive_data (network_data_nodes_list.network_data_nodes_IP_address [(int )(rand () % NETWORK_DATA_NODES_AMOUNT)],MESSAGE,SOCKET_CONNECTION_TIMEOUT_SETTINGS);
3831- sleep ( 1 );
3829+ std::this_thread::sleep_for ( std::chrono::milliseconds ( 1000 ) );
38323830 }
38333831
38343832 if (count == MAXIMUM_CONNECTION_TIMEOUT_SETTINGS)
0 commit comments