Skip to content

Commit fa34cb8

Browse files
author
MarcoFalke
committed
cli: Avoid truncating -rpcwaittimeout
1 parent d6e0d78 commit fa34cb8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/bitcoin-cli.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ static UniValue ConnectAndCallRPC(BaseRequestHandler* rh, const std::string& str
797797
// Execute and handle connection failures with -rpcwait.
798798
const bool fWait = gArgs.GetBoolArg("-rpcwait", false);
799799
const int timeout = gArgs.GetArg("-rpcwaittimeout", DEFAULT_WAIT_CLIENT_TIMEOUT);
800-
const int64_t deadline = GetTime<std::chrono::seconds>().count() + timeout;
800+
const auto deadline{GetTime<std::chrono::microseconds>() + 1s * timeout};
801801

802802
do {
803803
try {
@@ -810,9 +810,9 @@ static UniValue ConnectAndCallRPC(BaseRequestHandler* rh, const std::string& str
810810
}
811811
break; // Connection succeeded, no need to retry.
812812
} catch (const CConnectionFailed& e) {
813-
const int64_t now = GetTime<std::chrono::seconds>().count();
813+
const auto now{GetTime<std::chrono::microseconds>()};
814814
if (fWait && (timeout <= 0 || now < deadline)) {
815-
UninterruptibleSleep(std::chrono::seconds{1});
815+
UninterruptibleSleep(1s);
816816
} else {
817817
throw CConnectionFailed(strprintf("timeout on transient error: %s", e.what()));
818818
}

0 commit comments

Comments
 (0)