From 7e5cc4a431496eed6b3108fda056b195f3d72937 Mon Sep 17 00:00:00 2001 From: Stephane Janel Date: Sat, 26 Aug 2023 15:41:57 +0200 Subject: [PATCH] Upgrade dependencies, fix clang-tidy warnings --- CMakeLists.txt | 4 ++-- alpine.Dockerfile | 2 +- src/api/exchanges/src/binanceprivateapi.cpp | 9 ++++++--- src/api/exchanges/src/bithumbprivateapi.cpp | 3 --- src/objects/include/wallet.hpp | 2 +- src/objects/src/wallet.cpp | 4 ++-- src/tech/include/cct_hash.hpp | 12 ++++++------ src/tech/include/simpletable.hpp | 4 ++-- src/tech/include/stringhelpers.hpp | 4 ++-- src/tech/src/simpletable.cpp | 14 +++++++------- 10 files changed, 29 insertions(+), 29 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e831820d..9604fb02 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,7 +74,7 @@ if(CCT_ENABLE_TESTS) FetchContent_Declare( googletest GIT_REPOSITORY https://github.com/google/googletest.git - GIT_TAG v1.13.0 + GIT_TAG v1.14.0 ) FetchContent_MakeAvailable(googletest) @@ -99,7 +99,7 @@ if(NOT spdlog_FOUND) FetchContent_Declare( spdlog GIT_REPOSITORY https://github.com/gabime/spdlog.git - GIT_TAG v1.11.0 + GIT_TAG v1.12.0 ) FetchContent_MakeAvailable(spdlog) diff --git a/alpine.Dockerfile b/alpine.Dockerfile index f3c950b5..9e1bd1f5 100644 --- a/alpine.Dockerfile +++ b/alpine.Dockerfile @@ -1,5 +1,5 @@ # Multi stage build to separate docker build image from executable (to make the latter smaller) -FROM alpine:3.18.2 AS build +FROM alpine:3.18.3 AS build # Install base & build dependencies, needed certificates for curl to work with https RUN apk add --update --upgrade --no-cache g++ libc-dev curl-dev cmake ninja git ca-certificates diff --git a/src/api/exchanges/src/binanceprivateapi.cpp b/src/api/exchanges/src/binanceprivateapi.cpp index 079b83e0..0a339277 100644 --- a/src/api/exchanges/src/binanceprivateapi.cpp +++ b/src/api/exchanges/src/binanceprivateapi.cpp @@ -59,8 +59,8 @@ void SetNonceAndSignature(const APIKey& apiKey, CurlPostData& postData, Duration postData.append("signature", ssl::ShaHex(ssl::ShaType::kSha256, postData.str(), apiKey.privateKey())); } -bool CheckError(int statusCode, const json& ret, QueryDelayDir& queryDelayDir, Duration& sleepingTime, - Duration& queryDelay) { +bool CheckErrorDoRetry(int statusCode, const json& ret, QueryDelayDir& queryDelayDir, Duration& sleepingTime, + Duration& queryDelay) { static constexpr Duration kInitialDurationQueryDelay = std::chrono::milliseconds(200); switch (statusCode) { case kInvalidTimestamp: { @@ -108,6 +108,9 @@ bool CheckError(int statusCode, const json& ret, QueryDelayDir& queryDelayDir, D // Order does not exist : this may be possible when we query an order info too fast log::warn("Binance cannot find order"); return true; + case kInvalidApiKey: + log::error("Binance reported invalid API Key error"); + return false; default: break; } @@ -143,7 +146,7 @@ json PrivateQuery(CurlHandle& curlHandle, const APIKey& apiKey, HttpRequestType // error in query statusCode = *codeIt; // "1100" for instance - if (CheckError(statusCode, ret, queryDelayDir, sleepingTime, queryDelay)) { + if (CheckErrorDoRetry(statusCode, ret, queryDelayDir, sleepingTime, queryDelay)) { continue; } diff --git a/src/api/exchanges/src/bithumbprivateapi.cpp b/src/api/exchanges/src/bithumbprivateapi.cpp index 7eaf3b2b..d7582d1f 100644 --- a/src/api/exchanges/src/bithumbprivateapi.cpp +++ b/src/api/exchanges/src/bithumbprivateapi.cpp @@ -437,9 +437,6 @@ int BithumbPrivate::cancelOpenedOrders(const OrdersConstraints& openedOrdersCons } namespace { -constexpr int kSearchGbAll = 0; -constexpr int kSearchGbBuyCompleted = 1; -constexpr int kSearchGbSellCompleted = 2; constexpr int kSearchGbOnGoingWithdrawals = 3; constexpr int kSearchGbDeposit = 4; constexpr int kSearchGbProcessedWithdrawals = 5; diff --git a/src/objects/include/wallet.hpp b/src/objects/include/wallet.hpp index 7b1bafd9..8c85c0d3 100644 --- a/src/objects/include/wallet.hpp +++ b/src/objects/include/wallet.hpp @@ -36,7 +36,7 @@ class Wallet { /// Build a wallet with all information. Wallet(ExchangeName exchangeName, CurrencyCode currency, string address, std::string_view tag, - WalletCheck walletCheck, const AccountOwner &accountOwner); + WalletCheck walletCheck, AccountOwner accountOwner); const ExchangeName &exchangeName() const { return _exchangeName; } diff --git a/src/objects/src/wallet.cpp b/src/objects/src/wallet.cpp index cd9dc925..7741fbbb 100644 --- a/src/objects/src/wallet.cpp +++ b/src/objects/src/wallet.cpp @@ -60,10 +60,10 @@ bool Wallet::ValidateWallet(WalletCheck walletCheck, const ExchangeName &exchang } Wallet::Wallet(ExchangeName exchangeName, CurrencyCode currency, string address, std::string_view tag, - WalletCheck walletCheck, const AccountOwner &accountOwner) + WalletCheck walletCheck, AccountOwner accountOwner) : _exchangeName(std::move(exchangeName)), _addressAndTag(std::move(address)), - _accountOwner(accountOwner), + _accountOwner(std::move(accountOwner)), _tagPos(tag.empty() ? std::string_view::npos : _addressAndTag.size()), _currency(currency) { _addressAndTag.append(tag); diff --git a/src/tech/include/cct_hash.hpp b/src/tech/include/cct_hash.hpp index f0d0f5a4..f824c178 100644 --- a/src/tech/include/cct_hash.hpp +++ b/src/tech/include/cct_hash.hpp @@ -11,12 +11,12 @@ namespace cct { constexpr uint64_t HashValue64(uint64_t x) { // Murmur-inspired hashing. constexpr uint64_t kMul = 0x9ddfea08eb382d69ULL; - uint64_t b = x * kMul; - b ^= (b >> 44); - b *= kMul; - b ^= (b >> 41); - b *= kMul; - return b; + x *= kMul; + x ^= (x >> 44); + x *= kMul; + x ^= (x >> 41); + x *= kMul; + return x; } constexpr size_t HashCombine(size_t h1, size_t h2) { diff --git a/src/tech/include/simpletable.hpp b/src/tech/include/simpletable.hpp index 6ca1d665..d2307772 100644 --- a/src/tech/include/simpletable.hpp +++ b/src/tech/include/simpletable.hpp @@ -175,9 +175,9 @@ class SimpleTable { private: using MaxWidthPerColumnVector = SmallVector; - MaxWidthPerColumnVector computeMaxWidthPerColumn() const; + static Cell::string_type ComputeLineSep(std::span maxWidthPerColumnVector); - Cell::string_type computeLineSep(std::span maxWidthPerColumnVector) const; + MaxWidthPerColumnVector computeMaxWidthPerColumn() const; vector _rows; }; diff --git a/src/tech/include/stringhelpers.hpp b/src/tech/include/stringhelpers.hpp index 72cd9364..8521474e 100644 --- a/src/tech/include/stringhelpers.hpp +++ b/src/tech/include/stringhelpers.hpp @@ -16,7 +16,7 @@ namespace details { template inline void ToChars(char *first, SizeType s, std::integral auto i) { if (auto [ptr, errc] = std::to_chars(first, first + s, i); CCT_UNLIKELY(errc != std::errc())) { - throw exception("Unable to decode integral in string"); + throw exception("Unable to decode integral into string"); } } } // namespace details @@ -32,7 +32,7 @@ template Integral FromString(std::string_view str) { Integral ret; if (auto [ptr, errc] = std::from_chars(str.data(), str.data() + str.size(), ret); CCT_UNLIKELY(errc != std::errc())) { - throw exception("Unable to decode string in integral"); + throw exception("Unable to decode string into integral"); } return ret; } diff --git a/src/tech/src/simpletable.cpp b/src/tech/src/simpletable.cpp index 0f51a13d..9fade7e0 100644 --- a/src/tech/src/simpletable.cpp +++ b/src/tech/src/simpletable.cpp @@ -88,7 +88,7 @@ SimpleTable::MaxWidthPerColumnVector SimpleTable::computeMaxWidthPerColumn() con return res; } -SimpleTable::Cell::string_type SimpleTable::computeLineSep(std::span maxWidthPerColumnVector) const { +SimpleTable::Cell::string_type SimpleTable::ComputeLineSep(std::span maxWidthPerColumnVector) { const size_type sumWidths = std::accumulate(maxWidthPerColumnVector.begin(), maxWidthPerColumnVector.end(), 0U); // 3 as one space before, one space after the field name and column separator. +1 for the first column separator @@ -105,17 +105,17 @@ SimpleTable::Cell::string_type SimpleTable::computeLineSep(std::span 1U; - for (const auto &row : t._rows) { + bool printHeader = table._rows.size() > 1U; + for (const auto &row : table._rows) { if (row.isDivider()) { os << lineSep << std::endl; } else {