0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-08 10:31:50 -05:00

net: Use mockable steady clock in PCP implementation

This will be needed for the test harness.
This commit is contained in:
laanwj 2024-10-02 22:26:21 +02:00
parent 03648321ec
commit caf9521033

View file

@ -235,9 +235,9 @@ std::optional<std::vector<uint8_t>> PCPSendRecv(Sock &sock, const std::string &p
} }
// Wait for response(s) until we get a valid response, a network error, or time out. // Wait for response(s) until we get a valid response, a network error, or time out.
auto cur_time = time_point_cast<milliseconds>(steady_clock::now()); auto cur_time = time_point_cast<milliseconds>(MockableSteadyClock::now());
auto deadline = cur_time + timeout_per_try; auto deadline = cur_time + timeout_per_try;
while ((cur_time = time_point_cast<milliseconds>(steady_clock::now())) < deadline) { while ((cur_time = time_point_cast<milliseconds>(MockableSteadyClock::now())) < deadline) {
Sock::Event occurred = 0; Sock::Event occurred = 0;
if (!sock.Wait(deadline - cur_time, Sock::RECV, &occurred)) { if (!sock.Wait(deadline - cur_time, Sock::RECV, &occurred)) {
LogPrintLevel(BCLog::NET, BCLog::Level::Warning, "%s: Could not wait on socket: %s\n", protocol, NetworkErrorString(WSAGetLastError())); LogPrintLevel(BCLog::NET, BCLog::Level::Warning, "%s: Could not wait on socket: %s\n", protocol, NetworkErrorString(WSAGetLastError()));