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