aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/bootstrap_daemon.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/rpc/bootstrap_daemon.h')
-rw-r--r--src/rpc/bootstrap_daemon.h34
1 files changed, 26 insertions, 8 deletions
diff --git a/src/rpc/bootstrap_daemon.h b/src/rpc/bootstrap_daemon.h
index 6276b1b21..bedc255b5 100644
--- a/src/rpc/bootstrap_daemon.h
+++ b/src/rpc/bootstrap_daemon.h
@@ -1,26 +1,34 @@
#pragma once
#include <functional>
-#include <vector>
+#include <map>
#include <boost/optional/optional.hpp>
+#include <boost/thread/mutex.hpp>
#include <boost/utility/string_ref.hpp>
#include "net/http_client.h"
#include "storages/http_abstract_invoke.h"
+#include "bootstrap_node_selector.h"
+
namespace cryptonote
{
class bootstrap_daemon
{
public:
- bootstrap_daemon(std::function<boost::optional<std::string>()> get_next_public_node);
- bootstrap_daemon(const std::string &address, const boost::optional<epee::net_utils::http::login> &credentials);
+ bootstrap_daemon(
+ std::function<std::map<std::string, bool>()> get_public_nodes,
+ bool rpc_payment_enabled);
+ bootstrap_daemon(
+ const std::string &address,
+ boost::optional<epee::net_utils::http::login> credentials,
+ bool rpc_payment_enabled);
std::string address() const noexcept;
boost::optional<uint64_t> get_height();
- bool handle_result(bool success);
+ bool handle_result(bool success, const std::string &status);
template <class t_request, class t_response>
bool invoke_http_json(const boost::string_ref uri, const t_request &out_struct, t_response &result_struct)
@@ -30,7 +38,8 @@ namespace cryptonote
return false;
}
- return handle_result(epee::net_utils::invoke_http_json(uri, out_struct, result_struct, m_http_client));
+ const bool result = epee::net_utils::invoke_http_json(uri, out_struct, result_struct, m_http_client);
+ return handle_result(result, result_struct.status);
}
template <class t_request, class t_response>
@@ -41,7 +50,8 @@ namespace cryptonote
return false;
}
- return handle_result(epee::net_utils::invoke_http_bin(uri, out_struct, result_struct, m_http_client));
+ const bool result = epee::net_utils::invoke_http_bin(uri, out_struct, result_struct, m_http_client);
+ return handle_result(result, result_struct.status);
}
template <class t_request, class t_response>
@@ -52,7 +62,13 @@ namespace cryptonote
return false;
}
- return handle_result(epee::net_utils::invoke_http_json_rpc("/json_rpc", std::string(command_name.begin(), command_name.end()), out_struct, result_struct, m_http_client));
+ const bool result = epee::net_utils::invoke_http_json_rpc(
+ "/json_rpc",
+ std::string(command_name.begin(), command_name.end()),
+ out_struct,
+ result_struct,
+ m_http_client);
+ return handle_result(result, result_struct.status);
}
private:
@@ -61,7 +77,9 @@ namespace cryptonote
private:
epee::net_utils::http::http_simple_client m_http_client;
- std::function<boost::optional<std::string>()> m_get_next_public_node;
+ const bool m_rpc_payment_enabled;
+ const std::unique_ptr<bootstrap_node::selector> m_selector;
+ boost::mutex m_selector_mutex;
};
}