Skip to content

Commit

Permalink
Upgrade from c++17 to c++20
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Jung <104335080+AlexRamRam@users.noreply.github.com>
  • Loading branch information
AlexRamRam authored and HalosGhost committed Feb 29, 2024
1 parent b119956 commit 9715ff5
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 21 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ include(CheckCXXCompilerFlag)

project(opencbdc-tx)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_EXTENSIONS False)

Expand Down
1 change: 1 addition & 0 deletions benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ target_link_libraries(run_benchmarks ${GTEST_LIBRARY}
benchmark::benchmark
util
shard
watchtower
locking_shard
transaction
common
Expand Down
21 changes: 10 additions & 11 deletions src/parsec/broker/impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,8 @@ namespace cbdc::parsec::broker {

if(!m_directory->key_location(
key,
[=](std::optional<
parsec::directory::interface::key_location_return_type>
res) {
[=, this](std::optional<parsec::directory::interface::
key_location_return_type> res) {
handle_find_key(ticket_number,
key,
locktype,
Expand Down Expand Up @@ -296,8 +295,8 @@ namespace cbdc::parsec::broker {
auto sidx = shard.first;
if(!m_shards[sidx]->commit(
ticket_number,
[=](const parsec::runtime_locking_shard::interface::
commit_return_type& comm_res) {
[=, this](const parsec::runtime_locking_shard::interface::
commit_return_type& comm_res) {
handle_commit(commit_cb, ticket_number, sidx, comm_res);
})) {
m_log->error("Failed to make commit shard request");
Expand Down Expand Up @@ -545,8 +544,8 @@ namespace cbdc::parsec::broker {
shard.second.m_state = shard_state_type::finishing;
if(!m_shards[sidx]->finish(
ticket_number,
[=](const parsec::runtime_locking_shard::interface::
finish_return_type& res) {
[=, this](const parsec::runtime_locking_shard::
interface::finish_return_type& res) {
handle_finish(result_callback,
ticket_number,
sidx,
Expand Down Expand Up @@ -618,8 +617,8 @@ namespace cbdc::parsec::broker {
shard.second.m_state = shard_state_type::rolling_back;
if(!m_shards[sidx]->rollback(
ticket_number,
[=](const parsec::runtime_locking_shard::interface::
rollback_return_type& res) {
[=, this](const parsec::runtime_locking_shard::
interface::rollback_return_type& res) {
handle_rollback(result_callback,
ticket_number,
sidx,
Expand Down Expand Up @@ -783,8 +782,8 @@ namespace cbdc::parsec::broker {
key,
locktype,
first_lock,
[=](const parsec::runtime_locking_shard::interface::
try_lock_return_type& lock_res) {
[=, this](const parsec::runtime_locking_shard::interface::
try_lock_return_type& lock_res) {
handle_lock(ticket_number,
key,
shard_idx,
Expand Down
8 changes: 8 additions & 0 deletions src/uhs/atomizer/archiver/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
#include <utility>

namespace cbdc::archiver {

leveldbWriteOptions::leveldbWriteOptions(bool do_sync) {
// Set base class member:
sync = do_sync;
}

const leveldbWriteOptions controller::m_write_options{true};

controller::controller(uint32_t archiver_id,
cbdc::config::options opts,
std::shared_ptr<logging::log> log,
Expand Down
11 changes: 10 additions & 1 deletion src/uhs/atomizer/archiver/controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@
#include <leveldb/db.h>

namespace cbdc::archiver {

/// @brief Wrapper for leveldb::WriteOptions to provide a constructor to
/// set base class member "sync". The base class default constructor is
/// built with "= default;", and as a result - in c++20 - the single
/// parameter constructor is not available.
struct leveldbWriteOptions : public leveldb::WriteOptions {
explicit leveldbWriteOptions(bool do_sync);
};

/// \brief Wrapper for the archiver executable implementation.
///
/// Connects to the atomizer cluster to receive new blocks and listens for
Expand Down Expand Up @@ -138,7 +147,7 @@ namespace cbdc::archiver {

const std::string m_bestblock_key = "bestblock";
static constexpr const leveldb::ReadOptions m_read_options{};
static constexpr const leveldb::WriteOptions m_write_options{true};
static const leveldbWriteOptions m_write_options;

void request_block(uint64_t height);
void request_prune(uint64_t height);
Expand Down
9 changes: 5 additions & 4 deletions src/uhs/atomizer/atomizer/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,11 @@ namespace cbdc::atomizer {

void controller::tx_notify_handler() {
while(m_running) {
if(!m_raft_node.send_complete_txs([&](auto&& res, auto&& err) {
err_return_handler(std::forward<decltype(res)>(res),
std::forward<decltype(err)>(err));
})) {
if(!m_raft_node.send_complete_txs(
[&, this](auto&& res, auto&& err) {
err_return_handler(std::forward<decltype(res)>(res),
std::forward<decltype(err)>(err));
})) {
static constexpr auto batch_send_delay
= std::chrono::milliseconds(20);
std::this_thread::sleep_for(batch_send_delay);
Expand Down
2 changes: 1 addition & 1 deletion src/uhs/atomizer/sentinel/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ namespace cbdc::sentinel {
success
= m_sentinel_clients[sentinel_id]->validate_transaction(
tx,
[=](async_interface::validate_result v_res) {
[=, this](async_interface::validate_result v_res) {
auto r = requested;
r.insert(sentinel_id);
validate_result_handler(v_res, tx, ctx, r);
Expand Down
4 changes: 4 additions & 0 deletions src/uhs/transaction/transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ namespace cbdc::transaction {
return !(*this == rhs);
}

output::output(hash_t witness_program_commitment, uint64_t value)
: m_witness_program_commitment(witness_program_commitment),
m_value(value) {}

auto input::operator==(const input& rhs) const -> bool {
return m_prevout == rhs.m_prevout
&& m_prevout_data == rhs.m_prevout_data;
Expand Down
2 changes: 2 additions & 0 deletions src/uhs/transaction/transaction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ namespace cbdc::transaction {
auto operator==(const output& rhs) const -> bool;
auto operator!=(const output& rhs) const -> bool;

output(hash_t witness_program_commitment, uint64_t value);

output() = default;
};

Expand Down
2 changes: 1 addition & 1 deletion src/uhs/twophase/sentinel_2pc/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ namespace cbdc::sentinel_2pc {
success
= m_sentinel_clients[sentinel_id]->validate_transaction(
tx,
[=](validate_result v_res) {
[=, this](validate_result v_res) {
auto r = requested;
r.insert(sentinel_id);
validate_result_handler(v_res,
Expand Down
2 changes: 1 addition & 1 deletion tests/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace cbdc::test {
auto compact_transaction::operator==(
const transaction::compact_tx& tx) const noexcept -> bool {
const compact_transaction& tx) const noexcept -> bool {
return m_id == tx.m_id && (m_inputs == tx.m_inputs)
&& (m_uhs_outputs == tx.m_uhs_outputs);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace cbdc::test {
struct compact_transaction : cbdc::transaction::compact_tx {
compact_transaction() = default;
explicit compact_transaction(const compact_tx& transaction);
auto operator==(const compact_tx& tx) const noexcept -> bool;
auto operator==(const compact_transaction& tx) const noexcept -> bool;
};

/// Allows hashing \ref compact_transaction s (e.g., for storing them
Expand Down

0 comments on commit 9715ff5

Please sign in to comment.