mirror of
https://github.com/oxen-io/oxen-storage-server.git
synced 2023-12-13 21:00:26 +01:00
Switch to C++17
- updates lokimq to dev branch - changes compilation mode to C++17 (which is now required by lokimq, and already widely applied in lokinet and lokid dev branches) - replace lokimq::string_view with std::string_view - replace boost::optional with std::optional, except for: - boost::optional<std::function<...>> doesn't need optional at all because a std::function<...> is already nullable. - boost::optional<T&> isn't supported by std::optional because it makes little sense (it is just a `T*`) so just switch to T* instead.
This commit is contained in:
parent
8984c99138
commit
28f09402e6
|
@ -12,7 +12,8 @@ find_package(Boost
|
|||
filesystem
|
||||
)
|
||||
|
||||
set_property(TARGET common PROPERTY CXX_STANDARD 14)
|
||||
set_property(TARGET common PROPERTY CXX_STANDARD 17)
|
||||
set_property(TARGET common PROPERTY CXX_STANDARD_REQUIRED TRUE)
|
||||
|
||||
loki_add_subdirectory(../vendors/spdlog spdlog)
|
||||
|
||||
|
|
|
@ -47,7 +47,8 @@ target_link_libraries(httpserver_lib PUBLIC resolv)
|
|||
target_link_libraries(httpserver_lib PUBLIC crypto)
|
||||
target_link_libraries(httpserver_lib PUBLIC lokimq::lokimq)
|
||||
|
||||
set_property(TARGET httpserver_lib PROPERTY CXX_STANDARD 14)
|
||||
set_property(TARGET httpserver_lib PROPERTY CXX_STANDARD 17)
|
||||
set_property(TARGET httpserver_lib PROPERTY CXX_STANDARD_REQUIRED TRUE)
|
||||
|
||||
target_include_directories(httpserver_lib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${Boost_INCLUDE_DIRS})
|
||||
target_link_libraries(httpserver_lib PUBLIC ${Boost_LIBRARIES})
|
||||
|
@ -56,7 +57,8 @@ set(BIN_NAME loki-storage)
|
|||
|
||||
add_executable(httpserver main.cpp)
|
||||
set_target_properties(httpserver PROPERTIES OUTPUT_NAME ${BIN_NAME})
|
||||
set_property(TARGET httpserver PROPERTY CXX_STANDARD 14)
|
||||
set_property(TARGET httpserver PROPERTY CXX_STANDARD 17)
|
||||
set_property(TARGET httpserver_lib PROPERTY CXX_STANDARD_REQUIRED TRUE)
|
||||
target_link_libraries(httpserver PRIVATE httpserver_lib)
|
||||
install(TARGETS httpserver DESTINATION bin)
|
||||
# Build Info
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
#include "loki_logger.h"
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
|
|
@ -292,7 +292,7 @@ connection_t::connection_t(boost::asio::io_context& ioc, ssl::context& ssl_ctx,
|
|||
: ioc_(ioc), ssl_ctx_(ssl_ctx), socket_(std::move(socket)),
|
||||
stream_(socket_, ssl_ctx_), service_node_(sn), request_handler_(rh),
|
||||
rate_limiter_(rate_limiter), repeat_timer_(ioc),
|
||||
deadline_(ioc, SESSION_TIME_LIMIT), notification_ctx_{boost::none},
|
||||
deadline_(ioc, SESSION_TIME_LIMIT), notification_ctx_{std::nullopt},
|
||||
security_(security) {
|
||||
|
||||
static uint64_t instance_counter = 0;
|
||||
|
@ -352,7 +352,7 @@ void connection_t::on_handshake(boost::system::error_code ec) {
|
|||
|
||||
void connection_t::clean_up() { this->do_close(); }
|
||||
|
||||
void connection_t::notify(boost::optional<const message_t&> msg) {
|
||||
void connection_t::notify(const message_t* msg) {
|
||||
|
||||
if (!notification_ctx_) {
|
||||
LOKI_LOG(error,
|
||||
|
@ -363,7 +363,7 @@ void connection_t::notify(boost::optional<const message_t&> msg) {
|
|||
if (msg) {
|
||||
LOKI_LOG(trace, "Processing message notification: {}", msg->data);
|
||||
// save messages, so we can access them once the timer event happens
|
||||
notification_ctx_->message = msg;
|
||||
notification_ctx_->message = *msg;
|
||||
}
|
||||
// the timer callback will be called once we complete the current callback
|
||||
notification_ctx_->timer.cancel();
|
||||
|
@ -939,7 +939,7 @@ void connection_t::process_request() {
|
|||
this->process_swarm_req(target);
|
||||
break;
|
||||
}
|
||||
if (!service_node_.snode_ready(reason)) {
|
||||
if (!service_node_.snode_ready(&reason)) {
|
||||
LOKI_LOG(debug,
|
||||
"Ignoring post request; storage server not ready: {}",
|
||||
reason);
|
||||
|
@ -1041,7 +1041,7 @@ void connection_t::write_response() {
|
|||
|
||||
// Our last change to change the response before we start sending
|
||||
if (this->response_modifier_) {
|
||||
(*this->response_modifier_)(response_);
|
||||
this->response_modifier_(response_);
|
||||
}
|
||||
|
||||
response_.set(http::field::content_length, response_.body().size());
|
||||
|
@ -1361,7 +1361,7 @@ void HttpClientSession::start() {
|
|||
void HttpClientSession::trigger_callback(SNodeError error,
|
||||
std::shared_ptr<std::string>&& body) {
|
||||
LOKI_LOG(trace, "Trigger callback");
|
||||
ioc_.post(std::bind(callback_, sn_response_t{error, body, boost::none}));
|
||||
ioc_.post(std::bind(callback_, sn_response_t{error, body, std::nullopt}));
|
||||
used_callback_ = true;
|
||||
deadline_timer_.cancel();
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <iostream>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
|
||||
#include "../external/json.hpp"
|
||||
#include <boost/asio.hpp>
|
||||
|
@ -14,6 +15,7 @@
|
|||
#include <boost/filesystem.hpp>
|
||||
#include <boost/format.hpp>
|
||||
|
||||
#include "loki_common.h"
|
||||
#include "lokid_key.h"
|
||||
#include "swarm.h"
|
||||
|
||||
|
@ -39,7 +41,6 @@ namespace loki {
|
|||
std::shared_ptr<request_t> build_post_request(const char* target,
|
||||
std::string&& data);
|
||||
|
||||
struct message_t;
|
||||
struct Security;
|
||||
|
||||
class RequestHandler;
|
||||
|
@ -56,7 +57,7 @@ enum class SNodeError { NO_ERROR, ERROR_OTHER, NO_REACH, HTTP_ERROR };
|
|||
struct sn_response_t {
|
||||
SNodeError error_code;
|
||||
std::shared_ptr<std::string> body;
|
||||
boost::optional<response_t> raw_response;
|
||||
std::optional<response_t> raw_response;
|
||||
};
|
||||
|
||||
template <typename OStream>
|
||||
|
@ -222,16 +223,16 @@ class connection_t : public std::enable_shared_from_this<connection_t> {
|
|||
boost::asio::steady_timer timer;
|
||||
// the message is stored here momentarily; needed because
|
||||
// we can't pass it using current notification mechanism
|
||||
boost::optional<message_t> message;
|
||||
std::optional<message_t> message;
|
||||
// Messenger public key that this connection is registered for
|
||||
std::string pubkey;
|
||||
};
|
||||
|
||||
boost::optional<notification_context_t> notification_ctx_;
|
||||
std::optional<notification_context_t> notification_ctx_;
|
||||
|
||||
// If present, this function will be called just before
|
||||
// writing the response
|
||||
boost::optional<std::function<void(response_t&)>> response_modifier_;
|
||||
std::function<void(response_t&)> response_modifier_;
|
||||
|
||||
public:
|
||||
connection_t(boost::asio::io_context& ioc, ssl::context& ssl_ctx,
|
||||
|
@ -246,7 +247,7 @@ class connection_t : public std::enable_shared_from_this<connection_t> {
|
|||
/// Initiate the asynchronous operations associated with the connection.
|
||||
void start();
|
||||
|
||||
void notify(boost::optional<const message_t&> msg);
|
||||
void notify(const message_t* msg);
|
||||
|
||||
private:
|
||||
void do_handshake();
|
||||
|
|
|
@ -76,7 +76,7 @@ void make_https_request(boost::asio::io_context& ioc, const std::string& url,
|
|||
static ssl::context ctx{ssl::context::tlsv12_client};
|
||||
|
||||
auto session = std::make_shared<HttpsClientSession>(
|
||||
ioc, ctx, std::move(resolve_results), req, std::move(cb), boost::none);
|
||||
ioc, ctx, std::move(resolve_results), req, std::move(cb), nullptr);
|
||||
|
||||
session->start();
|
||||
};
|
||||
|
@ -111,10 +111,10 @@ HttpsClientSession::HttpsClientSession(
|
|||
boost::asio::io_context& ioc, ssl::context& ssl_ctx,
|
||||
tcp::resolver::results_type resolve_results,
|
||||
const std::shared_ptr<request_t>& req, http_callback_t&& cb,
|
||||
boost::optional<const std::string&> sn_pubkey_b32z)
|
||||
std::optional<std::string> sn_pubkey_b32z)
|
||||
: ioc_(ioc), ssl_ctx_(ssl_ctx), resolve_results_(resolve_results),
|
||||
callback_(cb), deadline_timer_(ioc), stream_(ioc, ssl_ctx_), req_(req),
|
||||
server_pub_key_b32z_(sn_pubkey_b32z) {
|
||||
server_pub_key_b32z_(std::move(sn_pubkey_b32z)) {
|
||||
|
||||
get_net_stats().https_connections_out++;
|
||||
|
||||
|
@ -195,7 +195,7 @@ void HttpsClientSession::on_connect() {
|
|||
void HttpsClientSession::on_handshake(boost::system::error_code ec) {
|
||||
if (ec) {
|
||||
LOKI_LOG(error, "Failed to perform a handshake with {}: {}",
|
||||
server_pub_key_b32z_ ? *server_pub_key_b32z_ : "(not snode)", ec.message());
|
||||
server_pub_key_b32z_.value_or("(not snode)"), ec.message());
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -286,7 +286,7 @@ void HttpsClientSession::on_read(error_code ec, size_t bytes_transferred) {
|
|||
|
||||
void HttpsClientSession::trigger_callback(
|
||||
SNodeError error, std::shared_ptr<std::string>&& body,
|
||||
boost::optional<response_t> raw_response) {
|
||||
std::optional<response_t> raw_response) {
|
||||
ioc_.post(std::bind(callback_, sn_response_t{error, body, raw_response}));
|
||||
used_callback_ = true;
|
||||
deadline_timer_.cancel();
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "http_connection.h"
|
||||
#include <optional>
|
||||
#include <functional>
|
||||
|
||||
namespace loki {
|
||||
|
@ -41,7 +42,7 @@ class HttpsClientSession
|
|||
response_t res_;
|
||||
|
||||
// Snode's pub key (none if signature verification is not used / not a snode)
|
||||
boost::optional<std::string> server_pub_key_b32z_;
|
||||
std::optional<std::string> server_pub_key_b32z_;
|
||||
|
||||
bool used_callback_ = false;
|
||||
|
||||
|
@ -53,7 +54,7 @@ class HttpsClientSession
|
|||
|
||||
void
|
||||
trigger_callback(SNodeError error, std::shared_ptr<std::string>&& body,
|
||||
boost::optional<response_t> raw_response = boost::none);
|
||||
std::optional<response_t> raw_response = std::nullopt);
|
||||
|
||||
void on_handshake(boost::system::error_code ec);
|
||||
bool verify_signature();
|
||||
|
@ -67,7 +68,7 @@ class HttpsClientSession
|
|||
tcp::resolver::results_type resolve_results,
|
||||
const std::shared_ptr<request_t>& req,
|
||||
http_callback_t&& cb,
|
||||
boost::optional<const std::string&> sn_pubkey_b32z);
|
||||
std::optional<std::string> sn_pubkey_b32z);
|
||||
|
||||
// initiate the client connection
|
||||
void start();
|
||||
|
|
|
@ -9,14 +9,16 @@
|
|||
|
||||
#include <lokimq/lokimq.h>
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace loki {
|
||||
|
||||
std::string LokimqServer::peer_lookup(lokimq::string_view pubkey_bin) const {
|
||||
std::string LokimqServer::peer_lookup(std::string_view pubkey_bin) const {
|
||||
|
||||
LOKI_LOG(trace, "[LMQ] Peer Lookup");
|
||||
|
||||
// TODO: don't create a new string here
|
||||
boost::optional<sn_record_t> sn =
|
||||
std::optional<sn_record_t> sn =
|
||||
this->service_node_->find_node_by_x25519_bin(std::string(pubkey_bin));
|
||||
|
||||
if (sn) {
|
||||
|
@ -130,7 +132,6 @@ void LokimqServer::init(ServiceNode* sn, RequestHandler* rh,
|
|||
const lokid_key_pair_t& keypair) {
|
||||
|
||||
using lokimq::Allow;
|
||||
using lokimq::string_view;
|
||||
|
||||
service_node_ = sn;
|
||||
request_handler_ = rh;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <lokimq/string_view.h>
|
||||
#include <string_view>
|
||||
|
||||
namespace lokimq {
|
||||
class LokiMQ;
|
||||
|
@ -29,7 +29,7 @@ class LokimqServer {
|
|||
RequestHandler* request_handler_;
|
||||
|
||||
// Get nodes' address
|
||||
std::string peer_lookup(lokimq::string_view pubkey_bin) const;
|
||||
std::string peer_lookup(std::string_view pubkey_bin) const;
|
||||
|
||||
// Handle Session data coming from peer SN
|
||||
void handle_sn_data(lokimq::Message& message);
|
||||
|
|
|
@ -28,16 +28,16 @@ extern "C" {
|
|||
|
||||
namespace fs = boost::filesystem;
|
||||
|
||||
static boost::optional<fs::path> get_home_dir() {
|
||||
static std::optional<fs::path> get_home_dir() {
|
||||
|
||||
/// TODO: support default dir for Windows
|
||||
#ifdef WIN32
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
#endif
|
||||
|
||||
char* pszHome = getenv("HOME");
|
||||
if (pszHome == NULL || strlen(pszHome) == 0)
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
|
||||
return fs::path(pszHome);
|
||||
}
|
||||
|
@ -76,10 +76,10 @@ int main(int argc, char* argv[]) {
|
|||
if (auto home_dir = get_home_dir()) {
|
||||
if (options.testnet) {
|
||||
options.data_dir =
|
||||
(home_dir.get() / ".loki" / "testnet" / "storage").string();
|
||||
(*home_dir / ".loki" / "testnet" / "storage").string();
|
||||
} else {
|
||||
options.data_dir =
|
||||
(home_dir.get() / ".loki" / "storage").string();
|
||||
(*home_dir / ".loki" / "storage").string();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -225,7 +225,7 @@ void reachability_records_t::set_reported(const sn_pub_key_t& sn) {
|
|||
}
|
||||
}
|
||||
|
||||
boost::optional<sn_pub_key_t> reachability_records_t::next_to_test() {
|
||||
std::optional<sn_pub_key_t> reachability_records_t::next_to_test() {
|
||||
|
||||
const auto it = std::min_element(
|
||||
offline_nodes_.begin(), offline_nodes_.end(),
|
||||
|
@ -234,7 +234,7 @@ boost::optional<sn_pub_key_t> reachability_records_t::next_to_test() {
|
|||
});
|
||||
|
||||
if (it == offline_nodes_.end()) {
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
} else {
|
||||
|
||||
LOKI_LOG(debug, "Selecting to be re-tested: {}", it->first);
|
||||
|
|
|
@ -80,7 +80,7 @@ class reachability_records_t {
|
|||
void set_reported(const sn_pub_key_t& sn);
|
||||
|
||||
// Retrun the least recently tested node
|
||||
boost::optional<sn_pub_key_t> next_to_test();
|
||||
std::optional<sn_pub_key_t> next_to_test();
|
||||
};
|
||||
|
||||
} // namespace loki
|
||||
|
|
|
@ -370,13 +370,13 @@ Response RequestHandler::wrap_proxy_response(const Response& res,
|
|||
}
|
||||
|
||||
void RequestHandler::process_lns_request(
|
||||
lokimq::string_view name_hash, std::function<void(loki::Response)> cb) {
|
||||
std::string name_hash, std::function<void(loki::Response)> cb) {
|
||||
|
||||
json params;
|
||||
json array = json::array();
|
||||
json entry;
|
||||
|
||||
entry["name_hash"] = name_hash;
|
||||
entry["name_hash"] = std::move(name_hash);
|
||||
|
||||
json types = json::array();
|
||||
types.push_back(0);
|
||||
|
@ -414,7 +414,7 @@ RequestHandler::process_onion_exit(const std::string& eph_key,
|
|||
|
||||
std::string body;
|
||||
|
||||
if (!service_node_.snode_ready(boost::none)) {
|
||||
if (!service_node_.snode_ready()) {
|
||||
cb({Status::SERVICE_UNAVAILABLE, "Snode not ready"});
|
||||
return;
|
||||
}
|
||||
|
@ -440,7 +440,7 @@ void RequestHandler::process_proxy_exit(
|
|||
const std::string& client_key, const std::string& payload,
|
||||
std::function<void(loki::Response)> cb) {
|
||||
|
||||
if (!service_node_.snode_ready(boost::none)) {
|
||||
if (!service_node_.snode_ready()) {
|
||||
auto res = Response{Status::SERVICE_UNAVAILABLE, "Snode not ready"};
|
||||
cb(wrap_proxy_response(res, client_key, false));
|
||||
return;
|
||||
|
@ -537,7 +537,7 @@ void RequestHandler::process_onion_req(const std::string& ciphertext,
|
|||
const std::string& ephem_key,
|
||||
std::function<void(loki::Response)> cb) {
|
||||
|
||||
if (!service_node_.snode_ready(boost::none)) {
|
||||
if (!service_node_.snode_ready()) {
|
||||
cb(loki::Response{Status::SERVICE_UNAVAILABLE, "Snode not ready"});
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include "loki_common.h"
|
||||
|
||||
#include <boost/asio.hpp>
|
||||
|
||||
// TODO: can I avoid including this in the header?
|
||||
#include "../external/json.hpp"
|
||||
#include <lokimq/string_view.h>
|
||||
|
||||
// TODO: move ChannelEncryption to ::loki
|
||||
template <typename T>
|
||||
|
@ -103,7 +102,7 @@ class RequestHandler {
|
|||
const std::string& payload,
|
||||
std::function<void(loki::Response)> cb);
|
||||
|
||||
void process_lns_request(lokimq::string_view name_hash,
|
||||
void process_lns_request(std::string name_hash,
|
||||
std::function<void(loki::Response)> cb);
|
||||
|
||||
// ===================================
|
||||
|
|
|
@ -94,11 +94,11 @@ struct string_view {
|
|||
bool empty() { return it_end <= it; }
|
||||
};
|
||||
|
||||
static boost::optional<std::string> deserialize_string(string_view& slice,
|
||||
static std::optional<std::string> deserialize_string(string_view& slice,
|
||||
size_t len) {
|
||||
|
||||
if (slice.size() < len) {
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
const auto res = std::string(slice.it, slice.it + len);
|
||||
|
@ -107,10 +107,10 @@ static boost::optional<std::string> deserialize_string(string_view& slice,
|
|||
return res;
|
||||
}
|
||||
|
||||
static boost::optional<std::string> deserialize_string(string_view& slice) {
|
||||
static std::optional<std::string> deserialize_string(string_view& slice) {
|
||||
|
||||
if (slice.size() < sizeof(size_t))
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
|
||||
const auto len =
|
||||
deserialize_integer<size_t>(slice.it); // already increments `it`!
|
||||
|
@ -118,10 +118,10 @@ static boost::optional<std::string> deserialize_string(string_view& slice) {
|
|||
return deserialize_string(slice, len);
|
||||
}
|
||||
|
||||
static boost::optional<uint64_t> deserialize_uint64(string_view& slice) {
|
||||
static std::optional<uint64_t> deserialize_uint64(string_view& slice) {
|
||||
|
||||
if (slice.size() < sizeof(uint64_t))
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
|
||||
const auto res = deserialize_integer<uint64_t>(slice.it);
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ static void make_sn_request(boost::asio::io_context& ioc, const sn_record_t& sn,
|
|||
FailedRequestHandler::FailedRequestHandler(
|
||||
boost::asio::io_context& ioc, const sn_record_t& sn,
|
||||
std::shared_ptr<request_t> req,
|
||||
boost::optional<std::function<void()>>&& give_up_cb)
|
||||
std::function<void()> give_up_cb)
|
||||
: ioc_(ioc), retry_timer_(ioc), sn_(sn), request_(std::move(req)),
|
||||
give_up_callback_(std::move(give_up_cb)) {}
|
||||
|
||||
|
@ -60,7 +60,7 @@ void FailedRequestHandler::retry(std::shared_ptr<FailedRequestHandler>&& self) {
|
|||
if (attempt_count_ > RETRY_INTERVALS.size()) {
|
||||
LOKI_LOG(debug, "Gave up after {} attempts", attempt_count_);
|
||||
if (give_up_callback_)
|
||||
(*give_up_callback_)();
|
||||
give_up_callback_();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -400,7 +400,7 @@ void ServiceNode::bootstrap_data() {
|
|||
}
|
||||
}
|
||||
|
||||
bool ServiceNode::snode_ready(boost::optional<std::string&> reason) {
|
||||
bool ServiceNode::snode_ready(std::string* reason) {
|
||||
|
||||
LockGuard guard(sn_mutex_);
|
||||
|
||||
|
@ -666,7 +666,7 @@ void ServiceNode::on_swarm_update(block_update_t&& bu) {
|
|||
swarm_->set_swarm_id(events.our_swarm_id);
|
||||
|
||||
std::string reason;
|
||||
if (!this->snode_ready(boost::optional<std::string&>(reason))) {
|
||||
if (!this->snode_ready(&reason)) {
|
||||
LOKI_LOG(warn, "Storage server is still not ready: {}", reason);
|
||||
swarm_->update_state(bu.swarms, bu.decommissioned_nodes, events, false);
|
||||
return;
|
||||
|
@ -887,7 +887,7 @@ void ServiceNode::ping_peers_tick() {
|
|||
const auto offline_node = reach_records_.next_to_test();
|
||||
|
||||
if (offline_node) {
|
||||
const boost::optional<sn_record_t> sn =
|
||||
const std::optional<sn_record_t> sn =
|
||||
swarm_->get_node_by_pk(*offline_node);
|
||||
LOKI_LOG(debug, "No offline nodes to test for reachability yet");
|
||||
if (sn) {
|
||||
|
@ -1910,7 +1910,7 @@ bool ServiceNode::is_snode_address_known(const std::string& sn_address) {
|
|||
return swarm_->is_fully_funded_node(sn_address);
|
||||
}
|
||||
|
||||
boost::optional<sn_record_t>
|
||||
std::optional<sn_record_t>
|
||||
ServiceNode::find_node_by_x25519_bin(const sn_pub_key_t& pk) const {
|
||||
|
||||
LockGuard guard(sn_mutex_);
|
||||
|
@ -1919,10 +1919,10 @@ ServiceNode::find_node_by_x25519_bin(const sn_pub_key_t& pk) const {
|
|||
return swarm_->find_node_by_x25519_bin(pk);
|
||||
}
|
||||
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
boost::optional<sn_record_t>
|
||||
std::optional<sn_record_t>
|
||||
ServiceNode::find_node_by_ed25519_pk(const std::string& pk) const {
|
||||
|
||||
LockGuard guard(sn_mutex_);
|
||||
|
@ -1931,7 +1931,7 @@ ServiceNode::find_node_by_ed25519_pk(const std::string& pk) const {
|
|||
return swarm_->find_node_by_ed25519_pk(pk);
|
||||
}
|
||||
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
} // namespace loki
|
||||
|
|
|
@ -6,11 +6,11 @@
|
|||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <optional>
|
||||
|
||||
#include <boost/asio.hpp>
|
||||
#include <boost/beast/http.hpp>
|
||||
#include <boost/circular_buffer.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
#include <boost/thread/thread.hpp>
|
||||
|
||||
#include "loki_common.h"
|
||||
|
@ -77,7 +77,7 @@ class FailedRequestHandler
|
|||
uint32_t attempt_count_ = 0;
|
||||
|
||||
/// Call this if we give up re-transmitting
|
||||
boost::optional<std::function<void()>> give_up_callback_;
|
||||
std::function<void()> give_up_callback_;
|
||||
|
||||
void retry(std::shared_ptr<FailedRequestHandler>&& self);
|
||||
|
||||
|
@ -85,7 +85,7 @@ class FailedRequestHandler
|
|||
FailedRequestHandler(
|
||||
boost::asio::io_context& ioc, const sn_record_t& sn,
|
||||
std::shared_ptr<request_t> req,
|
||||
boost::optional<std::function<void()>>&& give_up_cb = boost::none);
|
||||
std::function<void()> give_up_cb = nullptr);
|
||||
|
||||
~FailedRequestHandler();
|
||||
/// Initiates the timer for retrying (which cannot be done directly in
|
||||
|
@ -277,7 +277,7 @@ class ServiceNode {
|
|||
ss_client::Request req, ss_client::Callback cb) const;
|
||||
|
||||
// Return true if the service node is ready to start running
|
||||
bool snode_ready(boost::optional<std::string&> reason);
|
||||
bool snode_ready(std::string* reason = nullptr);
|
||||
|
||||
/// Process message received from a client, return false if not in a swarm
|
||||
bool process_store(const message_t& msg);
|
||||
|
@ -318,10 +318,10 @@ class ServiceNode {
|
|||
|
||||
std::string get_status_line() const;
|
||||
|
||||
boost::optional<sn_record_t>
|
||||
std::optional<sn_record_t>
|
||||
find_node_by_x25519_bin(const sn_pub_key_t& address) const;
|
||||
|
||||
boost::optional<sn_record_t>
|
||||
std::optional<sn_record_t>
|
||||
find_node_by_ed25519_pk(const std::string& pk) const;
|
||||
};
|
||||
|
||||
|
|
|
@ -229,10 +229,10 @@ void Swarm::update_state(const all_swarms_t& swarms,
|
|||
}
|
||||
}
|
||||
|
||||
boost::optional<sn_record_t> Swarm::choose_funded_node() const {
|
||||
std::optional<sn_record_t> Swarm::choose_funded_node() const {
|
||||
|
||||
if (all_funded_nodes_.empty())
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
|
||||
const auto idx =
|
||||
util::uniform_distribution_portable(all_funded_nodes_.size());
|
||||
|
@ -241,7 +241,7 @@ boost::optional<sn_record_t> Swarm::choose_funded_node() const {
|
|||
return all_funded_nodes_[idx];
|
||||
}
|
||||
|
||||
boost::optional<sn_record_t> Swarm::find_node_by_port(uint16_t port) const {
|
||||
std::optional<sn_record_t> Swarm::find_node_by_port(uint16_t port) const {
|
||||
|
||||
for (const auto &sn : all_funded_nodes_) {
|
||||
if (sn.port() == port) {
|
||||
|
@ -249,10 +249,10 @@ boost::optional<sn_record_t> Swarm::find_node_by_port(uint16_t port) const {
|
|||
}
|
||||
}
|
||||
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
boost::optional<sn_record_t>
|
||||
std::optional<sn_record_t>
|
||||
Swarm::find_node_by_ed25519_pk(const std::string& pk) const {
|
||||
|
||||
for (const auto& sn : all_funded_nodes_) {
|
||||
|
@ -261,10 +261,10 @@ Swarm::find_node_by_ed25519_pk(const std::string& pk) const {
|
|||
}
|
||||
}
|
||||
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
boost::optional<sn_record_t>
|
||||
std::optional<sn_record_t>
|
||||
Swarm::find_node_by_x25519_bin(const std::string& pk) const {
|
||||
|
||||
for (const auto& sn : all_funded_nodes_) {
|
||||
|
@ -273,10 +273,10 @@ Swarm::find_node_by_x25519_bin(const std::string& pk) const {
|
|||
}
|
||||
}
|
||||
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
boost::optional<sn_record_t>
|
||||
std::optional<sn_record_t>
|
||||
Swarm::get_node_by_pk(const sn_pub_key_t& pk) const {
|
||||
|
||||
for (const auto& sn : all_funded_nodes_) {
|
||||
|
@ -285,7 +285,7 @@ Swarm::get_node_by_pk(const sn_pub_key_t& pk) const {
|
|||
}
|
||||
}
|
||||
|
||||
return boost::none;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
static uint64_t hex_to_u64(const user_pubkey_t& pk) {
|
||||
|
|
|
@ -104,18 +104,18 @@ class Swarm {
|
|||
|
||||
// Select a node from all existing nodes (excluding us); throws if there is
|
||||
// no other nodes
|
||||
boost::optional<sn_record_t> choose_funded_node() const;
|
||||
std::optional<sn_record_t> choose_funded_node() const;
|
||||
|
||||
// TEMPORARY (TODO: change to finding by x25519 PK)
|
||||
boost::optional<sn_record_t> find_node_by_port(uint16_t port) const;
|
||||
std::optional<sn_record_t> find_node_by_port(uint16_t port) const;
|
||||
|
||||
// Get the node with public key `pk` if exists
|
||||
boost::optional<sn_record_t> get_node_by_pk(const sn_pub_key_t& pk) const;
|
||||
std::optional<sn_record_t> get_node_by_pk(const sn_pub_key_t& pk) const;
|
||||
|
||||
boost::optional<sn_record_t>
|
||||
std::optional<sn_record_t>
|
||||
find_node_by_ed25519_pk(const sn_pub_key_t& address) const;
|
||||
|
||||
boost::optional<sn_record_t>
|
||||
std::optional<sn_record_t>
|
||||
find_node_by_x25519_bin(const sn_pub_key_t& address) const;
|
||||
};
|
||||
|
||||
|
|
|
@ -5,7 +5,8 @@ add_library(pow STATIC
|
|||
|
||||
loki_add_subdirectory(../utils utils)
|
||||
|
||||
set_property(TARGET pow PROPERTY CXX_STANDARD 14)
|
||||
set_property(TARGET pow PROPERTY CXX_STANDARD 17)
|
||||
set_property(TARGET pow PROPERTY CXX_STANDARD_REQUIRED TRUE)
|
||||
|
||||
find_package(OpenSSL REQUIRED)
|
||||
target_link_libraries(pow PRIVATE OpenSSL::SSL)
|
||||
|
|
|
@ -4,7 +4,8 @@ add_library(storage STATIC
|
|||
src/Database.cpp
|
||||
)
|
||||
|
||||
set_property(TARGET storage PROPERTY CXX_STANDARD 14)
|
||||
set_property(TARGET storage PROPERTY CXX_STANDARD 17)
|
||||
set_property(TARGET storage PROPERTY CXX_STANDARD_REQUIRED TRUE)
|
||||
|
||||
target_include_directories(storage
|
||||
PUBLIC
|
||||
|
|
|
@ -30,7 +30,8 @@ find_package(Boost REQUIRED
|
|||
unit_test_framework
|
||||
)
|
||||
|
||||
set_property(TARGET Test PROPERTY CXX_STANDARD 14)
|
||||
set_property(TARGET Test PROPERTY CXX_STANDARD 17)
|
||||
set_property(TARGET Test PROPERTY CXX_STANDARD_REQUIRED TRUE)
|
||||
|
||||
target_include_directories(Test PRIVATE ${Boost_INCLUDE_DIRS})
|
||||
target_link_libraries(Test PRIVATE ${Boost_LIBRARIES})
|
||||
|
|
|
@ -11,7 +11,8 @@ find_package(Boost
|
|||
filesystem
|
||||
)
|
||||
|
||||
set_property(TARGET utils PROPERTY CXX_STANDARD 14)
|
||||
set_property(TARGET utils PROPERTY CXX_STANDARD 17)
|
||||
set_property(TARGET utils PROPERTY CXX_STANDARD_REQUIRED TRUE)
|
||||
|
||||
target_include_directories(utils
|
||||
PUBLIC
|
||||
|
|
2
vendors/loki-mq
vendored
2
vendors/loki-mq
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 1a65d7f5e521fb95fdbf16b2813628a507ea2043
|
||||
Subproject commit 30faadf01a561be8bda1b9fd78cd606bb209576a
|
Loading…
Reference in a new issue