From faa51780f3f8e6c5c0c4235499b95c246e074f29 Mon Sep 17 00:00:00 2001 From: Lee Clagett Date: Mon, 19 Apr 2021 00:49:14 -0400 Subject: [PATCH] Log exchange rate warning only once --- src/rest_server.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/rest_server.cpp b/src/rest_server.cpp index 9f2f9a0..0feaab0 100644 --- a/src/rest_server.cpp +++ b/src/rest_server.cpp @@ -132,6 +132,11 @@ namespace lws return {std::make_pair(user->second, std::move(*reader))}; } + namespace + { + std::atomic_flag rates_error_once = ATOMIC_FLAG_INIT; + } + struct get_address_info { using request = rpc::account_credentials; @@ -198,7 +203,7 @@ namespace lws } resp.rates = client.get_rates(); - if (!resp.rates) + if (!resp.rates && !rates_error_once.test_and_set(std::memory_order_relaxed)) MWARNING("Unable to retrieve exchange rates: " << resp.rates.error().message()); return resp;