Skip to content

Commit

Permalink
Upgrade dependencies, fix clang-tidy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
sjanel committed Aug 26, 2023
1 parent 17f9b01 commit 3fbd5ad
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 29 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion alpine.Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 6 additions & 3 deletions src/api/exchanges/src/binanceprivateapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}

Expand Down
3 changes: 0 additions & 3 deletions src/api/exchanges/src/bithumbprivateapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/objects/include/wallet.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

Expand Down
4 changes: 2 additions & 2 deletions src/objects/src/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 6 additions & 6 deletions src/tech/include/cct_hash.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions src/tech/include/simpletable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ class SimpleTable {
private:
using MaxWidthPerColumnVector = SmallVector<uint16_t, 8>;

MaxWidthPerColumnVector computeMaxWidthPerColumn() const;
static Cell::string_type ComputeLineSep(std::span<const uint16_t> maxWidthPerColumnVector);

Cell::string_type computeLineSep(std::span<const uint16_t> maxWidthPerColumnVector) const;
MaxWidthPerColumnVector computeMaxWidthPerColumn() const;

vector<Row> _rows;
};
Expand Down
4 changes: 2 additions & 2 deletions src/tech/include/stringhelpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace details {
template <class SizeType>
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
Expand All @@ -32,7 +32,7 @@ template <std::integral Integral>
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;
}
Expand Down
14 changes: 7 additions & 7 deletions src/tech/src/simpletable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ SimpleTable::MaxWidthPerColumnVector SimpleTable::computeMaxWidthPerColumn() con
return res;
}

SimpleTable::Cell::string_type SimpleTable::computeLineSep(std::span<const uint16_t> maxWidthPerColumnVector) const {
SimpleTable::Cell::string_type SimpleTable::ComputeLineSep(std::span<const uint16_t> 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
Expand All @@ -105,17 +105,17 @@ SimpleTable::Cell::string_type SimpleTable::computeLineSep(std::span<const uint1
return lineSep;
}

std::ostream &operator<<(std::ostream &os, const SimpleTable &t) {
if (t._rows.empty()) {
std::ostream &operator<<(std::ostream &os, const SimpleTable &table) {
if (table._rows.empty()) {
return os;
}
const auto maxWidthPerColumnVector = t.computeMaxWidthPerColumn();
const auto lineSep = t.computeLineSep(maxWidthPerColumnVector);
const auto maxWidthPerColumnVector = table.computeMaxWidthPerColumn();
const auto lineSep = SimpleTable::ComputeLineSep(maxWidthPerColumnVector);

os << lineSep << std::endl;

bool printHeader = t._rows.size() > 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 {
Expand Down

0 comments on commit 3fbd5ad

Please sign in to comment.