mirror of
https://github.com/Xahau/xahaud.git
synced 2025-11-04 10:45:50 +00:00
Switch from C++17 to C++20
This commit is contained in:
@@ -6,7 +6,7 @@ endif ()
|
||||
|
||||
project (rippled)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
# make GIT_COMMIT_HASH define available to all sources
|
||||
|
||||
@@ -421,7 +421,9 @@ RCLConsensus::Adaptor::onAccept(
|
||||
Json::Value&& consensusJson)
|
||||
{
|
||||
app_.getJobQueue().addJob(
|
||||
jtACCEPT, "acceptLedger", [=, cj = std::move(consensusJson)]() mutable {
|
||||
jtACCEPT,
|
||||
"acceptLedger",
|
||||
[=, this, cj = std::move(consensusJson)]() mutable {
|
||||
// Note that no lock is held or acquired during this job.
|
||||
// This is because generic Consensus guarantees that once a ledger
|
||||
// is accepted, the consensus results and capture by reference state
|
||||
|
||||
@@ -1125,10 +1125,10 @@ bookStepEqual(Step const& step, ripple::Book const& book)
|
||||
bool const inXRP = isXRP(book.in.currency);
|
||||
bool const outXRP = isXRP(book.out.currency);
|
||||
if (inXRP && outXRP)
|
||||
return equalHelper<
|
||||
XRPAmount,
|
||||
XRPAmount,
|
||||
BookPaymentStep<XRPAmount, XRPAmount>>(step, book);
|
||||
{
|
||||
assert(0);
|
||||
return false; // no such thing as xrp/xrp book step
|
||||
}
|
||||
if (inXRP && !outXRP)
|
||||
return equalHelper<
|
||||
XRPAmount,
|
||||
|
||||
@@ -684,7 +684,7 @@ private:
|
||||
{
|
||||
// strong, expired
|
||||
++cacheRemovals;
|
||||
if (cit->second.ptr.unique())
|
||||
if (cit->second.ptr.use_count() == 1)
|
||||
{
|
||||
stuffToSweep.push_back(cit->second.ptr);
|
||||
++mapRemovals;
|
||||
|
||||
@@ -77,12 +77,6 @@ protected:
|
||||
add(std::string const& key, signed char value);
|
||||
virtual void
|
||||
add(std::string const& key, unsigned char value);
|
||||
virtual void
|
||||
add(std::string const& key, wchar_t value);
|
||||
#if 0
|
||||
virtual void add (std::string const& key, char16_t value);
|
||||
virtual void add (std::string const& key, char32_t value);
|
||||
#endif
|
||||
virtual void
|
||||
add(std::string const& key, short value);
|
||||
virtual void
|
||||
@@ -139,12 +133,6 @@ protected:
|
||||
add(signed char value);
|
||||
virtual void
|
||||
add(unsigned char value);
|
||||
virtual void
|
||||
add(wchar_t value);
|
||||
#if 0
|
||||
virtual void add (char16_t value);
|
||||
virtual void add (char32_t value);
|
||||
#endif
|
||||
virtual void
|
||||
add(short value);
|
||||
virtual void
|
||||
|
||||
@@ -414,24 +414,6 @@ PropertyStream::add(std::string const& key, unsigned char value)
|
||||
lexical_add(key, value);
|
||||
}
|
||||
|
||||
void
|
||||
PropertyStream::add(std::string const& key, wchar_t value)
|
||||
{
|
||||
lexical_add(key, value);
|
||||
}
|
||||
|
||||
#if 0
|
||||
void PropertyStream::add (std::string const& key, char16_t value)
|
||||
{
|
||||
lexical_add (key, value);
|
||||
}
|
||||
|
||||
void PropertyStream::add (std::string const& key, char32_t value)
|
||||
{
|
||||
lexical_add (key, value);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
PropertyStream::add(std::string const& key, short value)
|
||||
{
|
||||
@@ -525,24 +507,6 @@ PropertyStream::add(unsigned char value)
|
||||
lexical_add(value);
|
||||
}
|
||||
|
||||
void
|
||||
PropertyStream::add(wchar_t value)
|
||||
{
|
||||
lexical_add(value);
|
||||
}
|
||||
|
||||
#if 0
|
||||
void PropertyStream::add (char16_t value)
|
||||
{
|
||||
lexical_add (value);
|
||||
}
|
||||
|
||||
void PropertyStream::add (char32_t value)
|
||||
{
|
||||
lexical_add (value);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
PropertyStream::add(short value)
|
||||
{
|
||||
|
||||
@@ -27,8 +27,10 @@
|
||||
#include <ripple/beast/container/aged_unordered_map.h>
|
||||
#include <ripple/consensus/LedgerTrie.h>
|
||||
#include <ripple/protocol/PublicKey.h>
|
||||
|
||||
#include <mutex>
|
||||
#include <optional>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
@@ -294,7 +296,7 @@ class Validations
|
||||
using NodeKey = typename Validation::NodeKey;
|
||||
|
||||
using WrappedValidationType = std::decay_t<
|
||||
std::result_of_t<decltype (&Validation::unwrap)(Validation)>>;
|
||||
std::invoke_result_t<decltype(&Validation::unwrap), Validation>>;
|
||||
|
||||
// Manages concurrent access to members
|
||||
mutable Mutex mutex_;
|
||||
|
||||
@@ -77,7 +77,7 @@ private:
|
||||
};
|
||||
|
||||
// List of tx, key order
|
||||
// Use the boost pmr functionality instead of the c++-17 standard pmr
|
||||
// Use boost::pmr functionality instead of std::pmr
|
||||
// functions b/c clang does not support pmr yet (as-of 9/2020)
|
||||
using txs_map = std::map<
|
||||
key_type,
|
||||
|
||||
@@ -119,7 +119,7 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
// Use the boost pmr functionality instead of the c++-17 standard pmr
|
||||
// Use boost::pmr functionality instead of the std::pmr
|
||||
// functions b/c clang does not support pmr yet (as-of 9/2020)
|
||||
using items_t = std::map<
|
||||
key_type,
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#include <ripple/basics/ByteUtilities.h>
|
||||
#include <ripple/basics/contract.h>
|
||||
#include <ripple/basics/safe_cast.h>
|
||||
#include <ripple/beast/core/CurrentThreadName.h>
|
||||
#include <ripple/core/Config.h> // VFALCO Bad dependency
|
||||
#include <ripple/nodestore/Factory.h>
|
||||
@@ -30,6 +31,7 @@
|
||||
#include <ripple/nodestore/impl/BatchWriter.h>
|
||||
#include <ripple/nodestore/impl/DecodedBlob.h>
|
||||
#include <ripple/nodestore/impl/EncodedBlob.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
|
||||
@@ -310,7 +312,8 @@ public:
|
||||
}
|
||||
else
|
||||
{
|
||||
status = Status(customCode + getStatus.code());
|
||||
status =
|
||||
Status(customCode + unsafe_cast<int>(getStatus.code()));
|
||||
|
||||
JLOG(m_journal.error()) << getStatus.ToString();
|
||||
}
|
||||
|
||||
@@ -494,16 +494,11 @@ template <typename clock_type>
|
||||
std::set<typename Peer::id_t>
|
||||
Slot<clock_type>::getSelected() const
|
||||
{
|
||||
std::set<id_t> init;
|
||||
return std::accumulate(
|
||||
peers_.begin(), peers_.end(), init, [](auto& init, auto const& it) {
|
||||
if (it.second.state == PeerState::Selected)
|
||||
{
|
||||
init.insert(it.first);
|
||||
return init;
|
||||
}
|
||||
return init;
|
||||
});
|
||||
std::set<id_t> r;
|
||||
for (auto const& [id, info] : peers_)
|
||||
if (info.state == PeerState::Selected)
|
||||
r.insert(id);
|
||||
return r;
|
||||
}
|
||||
|
||||
template <typename clock_type>
|
||||
@@ -513,20 +508,20 @@ std::unordered_map<
|
||||
Slot<clock_type>::getPeers() const
|
||||
{
|
||||
using namespace std::chrono;
|
||||
auto init = std::unordered_map<
|
||||
auto r = std::unordered_map<
|
||||
id_t,
|
||||
std::tuple<PeerState, std::uint16_t, std::uint32_t, std::uint32_t>>();
|
||||
return std::accumulate(
|
||||
peers_.begin(), peers_.end(), init, [](auto& init, auto const& it) {
|
||||
init.emplace(std::make_pair(
|
||||
it.first,
|
||||
std::move(std::make_tuple(
|
||||
it.second.state,
|
||||
it.second.count,
|
||||
epoch<milliseconds>(it.second.expire).count(),
|
||||
epoch<milliseconds>(it.second.lastMessage).count()))));
|
||||
return init;
|
||||
});
|
||||
|
||||
for (auto const& [id, info] : peers_)
|
||||
r.emplace(std::make_pair(
|
||||
id,
|
||||
std::move(std::make_tuple(
|
||||
info.state,
|
||||
info.count,
|
||||
epoch<milliseconds>(info.expire).count(),
|
||||
epoch<milliseconds>(info.lastMessage).count()))));
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
/** Slots is a container for validator's Slot and handles Slot update
|
||||
|
||||
@@ -2119,7 +2119,7 @@ PeerImp::onMessage(std::shared_ptr<protocol::TMStatusChange> const& m)
|
||||
m->ledgerseq(), app_.getLedgerMaster().getValidLedgerIndex());
|
||||
}
|
||||
|
||||
app_.getOPs().pubPeerStatus([=]() -> Json::Value {
|
||||
app_.getOPs().pubPeerStatus([=, this]() -> Json::Value {
|
||||
Json::Value j = Json::objectValue;
|
||||
|
||||
if (m->has_newstatus())
|
||||
|
||||
@@ -126,7 +126,6 @@ class FeatureBitset : private std::bitset<detail::numFeatures>
|
||||
public:
|
||||
using base::bitset;
|
||||
using base::operator==;
|
||||
using base::operator!=;
|
||||
|
||||
using base::all;
|
||||
using base::any;
|
||||
|
||||
@@ -251,22 +251,22 @@ public:
|
||||
}
|
||||
|
||||
bool
|
||||
operator==(Blob const& v)
|
||||
operator==(Blob const& v) const
|
||||
{
|
||||
return v == mData;
|
||||
}
|
||||
bool
|
||||
operator!=(Blob const& v)
|
||||
operator!=(Blob const& v) const
|
||||
{
|
||||
return v != mData;
|
||||
}
|
||||
bool
|
||||
operator==(const Serializer& v)
|
||||
operator==(const Serializer& v) const
|
||||
{
|
||||
return v.mData == mData;
|
||||
}
|
||||
bool
|
||||
operator!=(const Serializer& v)
|
||||
operator!=(const Serializer& v) const
|
||||
{
|
||||
return v.mData != mData;
|
||||
}
|
||||
|
||||
@@ -416,41 +416,42 @@ ShardArchiveHandler::complete(path dstPath)
|
||||
}
|
||||
|
||||
// Make lambdas mutable captured vars can be moved from
|
||||
auto wrapper = jobCounter_.wrap([=,
|
||||
dstPath = std::move(dstPath)]() mutable {
|
||||
if (stopping_)
|
||||
return;
|
||||
auto wrapper =
|
||||
jobCounter_.wrap([=, this, dstPath = std::move(dstPath)]() mutable {
|
||||
if (stopping_)
|
||||
return;
|
||||
|
||||
// If not synced then defer and retry
|
||||
auto const mode{app_.getOPs().getOperatingMode()};
|
||||
if (mode != OperatingMode::FULL)
|
||||
{
|
||||
std::lock_guard lock(m_);
|
||||
timer_.expires_from_now(static_cast<std::chrono::seconds>(
|
||||
(static_cast<std::size_t>(OperatingMode::FULL) -
|
||||
static_cast<std::size_t>(mode)) *
|
||||
10));
|
||||
// If not synced then defer and retry
|
||||
auto const mode{app_.getOPs().getOperatingMode()};
|
||||
if (mode != OperatingMode::FULL)
|
||||
{
|
||||
std::lock_guard lock(m_);
|
||||
timer_.expires_from_now(static_cast<std::chrono::seconds>(
|
||||
(static_cast<std::size_t>(OperatingMode::FULL) -
|
||||
static_cast<std::size_t>(mode)) *
|
||||
10));
|
||||
|
||||
auto wrapper = timerCounter_.wrap(
|
||||
[=, dstPath = std::move(dstPath)](
|
||||
boost::system::error_code const& ec) mutable {
|
||||
if (ec != boost::asio::error::operation_aborted)
|
||||
complete(std::move(dstPath));
|
||||
});
|
||||
auto wrapper = timerCounter_.wrap(
|
||||
[=, this, dstPath = std::move(dstPath)](
|
||||
boost::system::error_code const& ec) mutable {
|
||||
if (ec != boost::asio::error::operation_aborted)
|
||||
complete(std::move(dstPath));
|
||||
});
|
||||
|
||||
if (!wrapper)
|
||||
onClosureFailed(
|
||||
"failed to wrap closure for operating mode timer", lock);
|
||||
if (!wrapper)
|
||||
onClosureFailed(
|
||||
"failed to wrap closure for operating mode timer",
|
||||
lock);
|
||||
else
|
||||
timer_.async_wait(*wrapper);
|
||||
}
|
||||
else
|
||||
timer_.async_wait(*wrapper);
|
||||
}
|
||||
else
|
||||
{
|
||||
process(dstPath);
|
||||
std::lock_guard lock(m_);
|
||||
removeAndProceed(lock);
|
||||
}
|
||||
});
|
||||
{
|
||||
process(dstPath);
|
||||
std::lock_guard lock(m_);
|
||||
removeAndProceed(lock);
|
||||
}
|
||||
});
|
||||
|
||||
if (!wrapper)
|
||||
{
|
||||
|
||||
@@ -203,7 +203,7 @@ public:
|
||||
wait_for(std::chrono::duration<Rep, Period> const& rel_time)
|
||||
{
|
||||
std::unique_lock<std::mutex> lk(mutex_);
|
||||
auto b = cv_.wait_for(lk, rel_time, [=] { return signaled_; });
|
||||
auto b = cv_.wait_for(lk, rel_time, [this] { return signaled_; });
|
||||
signaled_ = false;
|
||||
return b;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
wait_for(std::chrono::duration<Rep, Period> const& rel_time)
|
||||
{
|
||||
std::unique_lock<std::mutex> lk(mutex_);
|
||||
auto b = cv_.wait_for(lk, rel_time, [=] { return signaled_; });
|
||||
auto b = cv_.wait_for(lk, rel_time, [this] { return signaled_; });
|
||||
signaled_ = false;
|
||||
return b;
|
||||
}
|
||||
|
||||
@@ -538,7 +538,7 @@ struct Peer
|
||||
ConsensusMode const& mode,
|
||||
Json::Value&& consensusJson)
|
||||
{
|
||||
schedule(delays.ledgerAccept, [=]() {
|
||||
schedule(delays.ledgerAccept, [=, this]() {
|
||||
const bool proposing = mode == ConsensusMode::proposing;
|
||||
const bool consensusFail = result.state == ConsensusState::MovedOn;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user