diff --git a/Makefile.am b/Makefile.am index 0a60fac3d..943eb918a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -58,6 +58,7 @@ src_libbitcoin_node_la_SOURCES = \ src/protocols/protocol_block_in_31800.cpp \ src/protocols/protocol_block_out_106.cpp \ src/protocols/protocol_block_out_70012.cpp \ + src/protocols/protocol_explore.cpp \ src/protocols/protocol_filter_out_70015.cpp \ src/protocols/protocol_header_in_31800.cpp \ src/protocols/protocol_header_in_70012.cpp \ @@ -180,6 +181,7 @@ include_bitcoin_node_protocols_HEADERS = \ include/bitcoin/node/protocols/protocol_block_in_31800.hpp \ include/bitcoin/node/protocols/protocol_block_out_106.hpp \ include/bitcoin/node/protocols/protocol_block_out_70012.hpp \ + include/bitcoin/node/protocols/protocol_explore.hpp \ include/bitcoin/node/protocols/protocol_filter_out_70015.hpp \ include/bitcoin/node/protocols/protocol_header_in_31800.hpp \ include/bitcoin/node/protocols/protocol_header_in_70012.hpp \ diff --git a/builds/cmake/CMakeLists.txt b/builds/cmake/CMakeLists.txt index 013e630e6..0915effc5 100644 --- a/builds/cmake/CMakeLists.txt +++ b/builds/cmake/CMakeLists.txt @@ -270,6 +270,7 @@ add_library( ${CANONICAL_LIB_NAME} "../../src/protocols/protocol_block_in_31800.cpp" "../../src/protocols/protocol_block_out_106.cpp" "../../src/protocols/protocol_block_out_70012.cpp" + "../../src/protocols/protocol_explore.cpp" "../../src/protocols/protocol_filter_out_70015.cpp" "../../src/protocols/protocol_header_in_31800.cpp" "../../src/protocols/protocol_header_in_70012.cpp" diff --git a/builds/msvc/vs2022/libbitcoin-node/libbitcoin-node.vcxproj b/builds/msvc/vs2022/libbitcoin-node/libbitcoin-node.vcxproj index ae228404a..70940f6e0 100644 --- a/builds/msvc/vs2022/libbitcoin-node/libbitcoin-node.vcxproj +++ b/builds/msvc/vs2022/libbitcoin-node/libbitcoin-node.vcxproj @@ -143,6 +143,7 @@ + @@ -187,6 +188,7 @@ + diff --git a/builds/msvc/vs2022/libbitcoin-node/libbitcoin-node.vcxproj.filters b/builds/msvc/vs2022/libbitcoin-node/libbitcoin-node.vcxproj.filters index 19b037be2..5b350838e 100644 --- a/builds/msvc/vs2022/libbitcoin-node/libbitcoin-node.vcxproj.filters +++ b/builds/msvc/vs2022/libbitcoin-node/libbitcoin-node.vcxproj.filters @@ -114,6 +114,9 @@ src\protocols + + src\protocols + src\protocols @@ -242,6 +245,9 @@ include\bitcoin\node\protocols + + include\bitcoin\node\protocols + include\bitcoin\node\protocols diff --git a/include/bitcoin/node.hpp b/include/bitcoin/node.hpp index 09a2879bd..64146c496 100644 --- a/include/bitcoin/node.hpp +++ b/include/bitcoin/node.hpp @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include diff --git a/include/bitcoin/node/define.hpp b/include/bitcoin/node/define.hpp index 96b7b530c..a9cdde479 100644 --- a/include/bitcoin/node/define.hpp +++ b/include/bitcoin/node/define.hpp @@ -120,10 +120,9 @@ using type_id = network::messages::peer::inventory_item::type_id; // settings : define // configuration : define settings // parser : define configuration -// /chasers : define configuration [forward: full_node] +// /chasers : define configuration [forward: full_node] // full_node : define /chasers -// session : define full_node -// /protocols : define session - -// Session is only included by full_node.cpp (avoids cycle). -// /sessions : define full_node /protocols \ No newline at end of file +// attach : define session [forward: full_node] +// session : define [forward: full_node] +// /sessions : define attach /protocols [forward: full_node] +// /protocols : define session \ No newline at end of file diff --git a/include/bitcoin/node/full_node.hpp b/include/bitcoin/node/full_node.hpp index 70af73e4e..90fc5833c 100644 --- a/include/bitcoin/node/full_node.hpp +++ b/include/bitcoin/node/full_node.hpp @@ -25,6 +25,8 @@ #include #include #include +////#include +////#include namespace libbitcoin { namespace node { @@ -40,9 +42,9 @@ class BCN_API full_node : public network::net { public: - using memory_controller = block_memory; using store = node::store; using query = node::query; + using memory_controller = block_memory; typedef std::shared_ptr ptr; /// Constructors. diff --git a/include/bitcoin/node/protocols/protocol_block_in_106.hpp b/include/bitcoin/node/protocols/protocol_block_in_106.hpp index f75ecf5a8..10a4e0d6f 100644 --- a/include/bitcoin/node/protocols/protocol_block_in_106.hpp +++ b/include/bitcoin/node/protocols/protocol_block_in_106.hpp @@ -34,9 +34,7 @@ class BCN_API protocol_block_in_106 public: typedef std::shared_ptr ptr; - BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT) - template - protocol_block_in_106(const SessionPtr& session, + protocol_block_in_106(const auto& session, const network::channel::ptr& channel) NOEXCEPT : node::protocol(session, channel), block_type_(session->config().network.witness_node() ? @@ -44,7 +42,6 @@ class BCN_API protocol_block_in_106 network::tracker(session->log) { } - BC_POP_WARNING() /// Start/stop protocol (strand required). void start() NOEXCEPT override; diff --git a/include/bitcoin/node/protocols/protocol_block_in_31800.hpp b/include/bitcoin/node/protocols/protocol_block_in_31800.hpp index c69202639..2a31b9e69 100644 --- a/include/bitcoin/node/protocols/protocol_block_in_31800.hpp +++ b/include/bitcoin/node/protocols/protocol_block_in_31800.hpp @@ -35,9 +35,7 @@ class BCN_API protocol_block_in_31800 public: typedef std::shared_ptr ptr; - BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT) - template - protocol_block_in_31800(const SessionPtr& session, + protocol_block_in_31800(const auto& session, const network::channel::ptr& channel, bool performance_enabled=true) NOEXCEPT : protocol_performer(session, channel, performance_enabled), top_checkpoint_height_( @@ -48,7 +46,6 @@ class BCN_API protocol_block_in_31800 network::tracker(session->log) { } - BC_POP_WARNING() /// Start/stop protocol (strand required). void start() NOEXCEPT override; diff --git a/include/bitcoin/node/protocols/protocol_block_out_106.hpp b/include/bitcoin/node/protocols/protocol_block_out_106.hpp index d88b2fb7d..d3d5e78a5 100644 --- a/include/bitcoin/node/protocols/protocol_block_out_106.hpp +++ b/include/bitcoin/node/protocols/protocol_block_out_106.hpp @@ -33,8 +33,7 @@ class BCN_API protocol_block_out_106 public: typedef std::shared_ptr ptr; - template - protocol_block_out_106(const SessionPtr& session, + protocol_block_out_106(const auto& session, const network::channel::ptr& channel) NOEXCEPT : node::protocol(session, channel), node_witness_(session->config().network.witness_node()), diff --git a/include/bitcoin/node/protocols/protocol_block_out_70012.hpp b/include/bitcoin/node/protocols/protocol_block_out_70012.hpp index 967ce4c43..7efc706e8 100644 --- a/include/bitcoin/node/protocols/protocol_block_out_70012.hpp +++ b/include/bitcoin/node/protocols/protocol_block_out_70012.hpp @@ -33,8 +33,7 @@ class BCN_API protocol_block_out_70012 public: typedef std::shared_ptr ptr; - template - protocol_block_out_70012(const SessionPtr& session, + protocol_block_out_70012(const auto& session, const network::channel::ptr& channel) NOEXCEPT : protocol_block_out_106(session, channel), network::tracker(session->log) diff --git a/include/bitcoin/node/protocols/protocol_explore.hpp b/include/bitcoin/node/protocols/protocol_explore.hpp new file mode 100644 index 000000000..f84525511 --- /dev/null +++ b/include/bitcoin/node/protocols/protocol_explore.hpp @@ -0,0 +1,60 @@ +/** + * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +#ifndef LIBBITCOIN_NODE_PROTOCOLS_PROTOCOL_EXPLORE_HPP +#define LIBBITCOIN_NODE_PROTOCOLS_PROTOCOL_EXPLORE_HPP + +#include +#include +#include +#include + +namespace libbitcoin { +namespace node { + +class BCN_API protocol_explore + : public network::protocol_html, + protected network::tracker +{ +public: + typedef std::shared_ptr ptr; + using options_t = network::settings::html_server; + using channel_t = network::channel_http; + + protocol_explore(const auto& session, + const network::channel::ptr& channel, + const options_t& options) NOEXCEPT + : network::protocol_html(session, channel, options), + ////options_(options), + network::tracker(session->log) + { + } + +protected: + void handle_receive_get(const code& ec, + const network::http::method::get& request) NOEXCEPT override; + +private: + // This is thread safe. + ////const options_t& options_; +}; + +} // namespace node +} // namespace libbitcoin + +#endif diff --git a/include/bitcoin/node/protocols/protocol_filter_out_70015.hpp b/include/bitcoin/node/protocols/protocol_filter_out_70015.hpp index cbc06c778..18e02ff9f 100644 --- a/include/bitcoin/node/protocols/protocol_filter_out_70015.hpp +++ b/include/bitcoin/node/protocols/protocol_filter_out_70015.hpp @@ -34,8 +34,7 @@ class BCN_API protocol_filter_out_70015 public: typedef std::shared_ptr ptr; - template - protocol_filter_out_70015(const SessionPtr& session, + protocol_filter_out_70015(const auto& session, const network::channel::ptr& channel) NOEXCEPT : node::protocol(session, channel), network::tracker(session->log) diff --git a/include/bitcoin/node/protocols/protocol_header_in_31800.hpp b/include/bitcoin/node/protocols/protocol_header_in_31800.hpp index 6c4651ae7..a53799c3f 100644 --- a/include/bitcoin/node/protocols/protocol_header_in_31800.hpp +++ b/include/bitcoin/node/protocols/protocol_header_in_31800.hpp @@ -33,8 +33,7 @@ class BCN_API protocol_header_in_31800 public: typedef std::shared_ptr ptr; - template - protocol_header_in_31800(const SessionPtr& session, + protocol_header_in_31800(const auto& session, const network::channel::ptr& channel) NOEXCEPT : node::protocol(session, channel), network::tracker(session->log) diff --git a/include/bitcoin/node/protocols/protocol_header_in_70012.hpp b/include/bitcoin/node/protocols/protocol_header_in_70012.hpp index 6ced13d66..7f081c2dd 100644 --- a/include/bitcoin/node/protocols/protocol_header_in_70012.hpp +++ b/include/bitcoin/node/protocols/protocol_header_in_70012.hpp @@ -33,8 +33,7 @@ class BCN_API protocol_header_in_70012 public: typedef std::shared_ptr ptr; - template - protocol_header_in_70012(const SessionPtr& session, + protocol_header_in_70012(const auto& session, const network::channel::ptr& channel) NOEXCEPT : node::protocol_header_in_31800(session, channel), network::tracker(session->log) diff --git a/include/bitcoin/node/protocols/protocol_header_out_31800.hpp b/include/bitcoin/node/protocols/protocol_header_out_31800.hpp index 70b31db87..68faa9a59 100644 --- a/include/bitcoin/node/protocols/protocol_header_out_31800.hpp +++ b/include/bitcoin/node/protocols/protocol_header_out_31800.hpp @@ -33,8 +33,7 @@ class BCN_API protocol_header_out_31800 public: typedef std::shared_ptr ptr; - template - protocol_header_out_31800(const SessionPtr& session, + protocol_header_out_31800(const auto& session, const network::channel::ptr& channel) NOEXCEPT : node::protocol(session, channel), network::tracker(session->log) diff --git a/include/bitcoin/node/protocols/protocol_header_out_70012.hpp b/include/bitcoin/node/protocols/protocol_header_out_70012.hpp index da0a91f4b..eed6ba5c3 100644 --- a/include/bitcoin/node/protocols/protocol_header_out_70012.hpp +++ b/include/bitcoin/node/protocols/protocol_header_out_70012.hpp @@ -33,8 +33,7 @@ class BCN_API protocol_header_out_70012 public: typedef std::shared_ptr ptr; - template - protocol_header_out_70012(const SessionPtr& session, + protocol_header_out_70012(const auto& session, const network::channel::ptr& channel) NOEXCEPT : node::protocol_header_out_31800(session, channel), network::tracker(session->log) diff --git a/include/bitcoin/node/protocols/protocol_observer.hpp b/include/bitcoin/node/protocols/protocol_observer.hpp index 9202de958..34cefdde5 100644 --- a/include/bitcoin/node/protocols/protocol_observer.hpp +++ b/include/bitcoin/node/protocols/protocol_observer.hpp @@ -36,8 +36,7 @@ class BCN_API protocol_observer // TODO: consider relay may be dynamic (disallowed until current). // TODO: current network handshake sets relay based on config only. - template - protocol_observer(const SessionPtr& session, + protocol_observer(const auto& session, const network::channel::ptr& channel) NOEXCEPT : node::protocol(session, channel), relay_disallowed_ diff --git a/include/bitcoin/node/protocols/protocol_performer.hpp b/include/bitcoin/node/protocols/protocol_performer.hpp index 6453a5f95..a50ee93ba 100644 --- a/include/bitcoin/node/protocols/protocol_performer.hpp +++ b/include/bitcoin/node/protocols/protocol_performer.hpp @@ -38,8 +38,7 @@ class BCN_API protocol_performer virtual void count(size_t bytes) NOEXCEPT; protected: - template - protocol_performer(const SessionPtr& session, + protocol_performer(const auto& session, const network::channel::ptr& channel, bool enabled) NOEXCEPT : node::protocol(session, channel), deviation_(session->config().node.allowed_deviation > 0.0), diff --git a/include/bitcoin/node/protocols/protocol_transaction_in_106.hpp b/include/bitcoin/node/protocols/protocol_transaction_in_106.hpp index 87b57b114..60277c98c 100644 --- a/include/bitcoin/node/protocols/protocol_transaction_in_106.hpp +++ b/include/bitcoin/node/protocols/protocol_transaction_in_106.hpp @@ -33,8 +33,7 @@ class BCN_API protocol_transaction_in_106 public: typedef std::shared_ptr ptr; - template - protocol_transaction_in_106(const SessionPtr& session, + protocol_transaction_in_106(const auto& session, const network::channel::ptr& channel) NOEXCEPT : node::protocol(session, channel), ////tx_type_(session->config().network.witness_node() ? diff --git a/include/bitcoin/node/protocols/protocol_transaction_out_106.hpp b/include/bitcoin/node/protocols/protocol_transaction_out_106.hpp index 8ed5421bc..0678725db 100644 --- a/include/bitcoin/node/protocols/protocol_transaction_out_106.hpp +++ b/include/bitcoin/node/protocols/protocol_transaction_out_106.hpp @@ -33,8 +33,7 @@ class BCN_API protocol_transaction_out_106 public: typedef std::shared_ptr ptr; - template - protocol_transaction_out_106(const SessionPtr& session, + protocol_transaction_out_106(const auto& session, const network::channel::ptr& channel) NOEXCEPT : node::protocol(session, channel), node_witness_(session->config().network.witness_node()), diff --git a/include/bitcoin/node/protocols/protocols.hpp b/include/bitcoin/node/protocols/protocols.hpp index e15cfb949..47bdebbd6 100644 --- a/include/bitcoin/node/protocols/protocols.hpp +++ b/include/bitcoin/node/protocols/protocols.hpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include diff --git a/include/bitcoin/node/sessions/attach.hpp b/include/bitcoin/node/sessions/attach.hpp index cbaa90e82..a85f0aab6 100644 --- a/include/bitcoin/node/sessions/attach.hpp +++ b/include/bitcoin/node/sessions/attach.hpp @@ -28,7 +28,7 @@ namespace libbitcoin { namespace node { -class session_outbound; +class full_node; /// Session base class template for protocol attachment. /// node::session does not derive from network::session (siblings). @@ -40,21 +40,7 @@ class attach { public: attach(full_node& node, uint64_t identifier) NOEXCEPT - : Session(node, identifier), - session(node), - relay_(node.config().network.enable_relay), - delay_(node.config().node.delay_inbound), - headers_(node.config().node.headers_first), - node_network_(to_bool(system::bit_and - ( - node.config().network.services_maximum, - network::messages::peer::service::node_network - ))), - node_client_filters_(to_bool(system::bit_and - ( - node.config().network.services_maximum, - network::messages::peer::service::node_client_filters - ))) + : Session(node, identifier), session(node) { } @@ -72,7 +58,22 @@ class attach void attach_protocols(const network::channel::ptr& channel) NOEXCEPT override { + using namespace system; using namespace network::messages::peer; + const auto relay = config().network.enable_relay; + const auto delay = config().node.delay_inbound; + const auto headers = config().node.headers_first; + const auto node_network = to_bool(bit_and + ( + config().network.services_maximum, + network::messages::peer::service::node_network + )); + const auto node_client_filters = to_bool(bit_and + ( + config().network.services_maximum, + network::messages::peer::service::node_client_filters + )); + const auto self = session::shared_from_sibling, network::session>(); @@ -83,7 +84,7 @@ class attach channel->attach(self)->start(); // Ready to relay blocks or block filters. - const auto blocks_out = !delay_ || is_recent(); + const auto blocks_out = !delay || is_recent(); /////////////////////////////////////////////////////////////////////// // bip152: "Upon receipt of a `sendcmpct` message with the first and @@ -96,28 +97,28 @@ class attach channel); // Node must advertise node_client_filters or no out filters. - if (node_client_filters_ && blocks_out && + if (node_client_filters && blocks_out && peer->is_negotiated(level::bip157)) channel->attach(self)->start(); // Node must advertise node_network or no in|out blocks|txs. - if (!node_network_) + if (!node_network) return; // Ready to relay transactions. - const auto txs_in_out = relay_ && peer->is_negotiated(level::bip37) && - (!delay_ || is_current(true)); + const auto txs_in_out = relay && peer->is_negotiated(level::bip37) && + (!delay || is_current(true)); // Peer advertises chain (blocks in). if (peer->is_peer_service(service::node_network)) { - if (headers_ && peer->is_negotiated(level::bip130)) + if (headers && peer->is_negotiated(level::bip130)) { channel->attach(self)->start(); channel->attach(self)->start(); } - else if (headers_ && peer->is_negotiated(level::headers_protocol)) + else if (headers && peer->is_negotiated(level::headers_protocol)) { channel->attach(self)->start(); channel->attach(self)->start(); @@ -133,12 +134,12 @@ class attach // Blocks are ready (blocks out). if (blocks_out) { - if (headers_ && peer->is_negotiated(level::bip130)) + if (headers && peer->is_negotiated(level::bip130)) { channel->attach(self)->start(); channel->attach(self)->start(); } - else if (headers_ && peer->is_negotiated(level::headers_protocol)) + else if (headers && peer->is_negotiated(level::headers_protocol)) { channel->attach(self)->start(); channel->attach(self)->start(); @@ -164,14 +165,6 @@ class attach network::session::log, socket, node::session::config(), network::session::create_key())); } - -private: - // These are thread safe. - const bool relay_; - const bool delay_; - const bool headers_; - const bool node_network_; - const bool node_client_filters_; }; } // namespace node diff --git a/include/bitcoin/node/sessions/session.hpp b/include/bitcoin/node/sessions/session.hpp index 8122bcad0..4c8aa1e38 100644 --- a/include/bitcoin/node/sessions/session.hpp +++ b/include/bitcoin/node/sessions/session.hpp @@ -21,12 +21,14 @@ #include #include +#include #include -#include namespace libbitcoin { namespace node { - + + class full_node; + /// Common session context, presumes will be joined with network::session. /// This could be templatized on the sibling, but there only one implemented. class BCN_API session @@ -93,7 +95,7 @@ class BCN_API session /// ----------------------------------------------------------------------- /// Thread safe synchronous archival interface. - full_node::query& archive() const NOEXCEPT; + node::query& archive() const NOEXCEPT; /// Configuration settings for all libraries. const configuration& config() const NOEXCEPT; diff --git a/install-cmake.sh b/install-cmake.sh index cde80f803..dbcfc7f31 100755 --- a/install-cmake.sh +++ b/install-cmake.sh @@ -60,7 +60,7 @@ fi # The default build directory. #------------------------------------------------------------------------------ -BUILD_DIR="build-libbitcoin-node" +BUILD_SRC_DIR="build-libbitcoin-node" PRESUMED_CI_PROJECT_PATH=$(pwd) @@ -162,13 +162,13 @@ make_jobs() shift 1 VERBOSITY="" - if [[ DISPLAY_VERBOSE ]]; then + if [[ $DISPLAY_VERBOSE ]]; then VERBOSITY="VERBOSE=1" fi SEQUENTIAL=1 # Avoid setting -j1 (causes problems on single threaded systems [TRAVIS]). - if [[ $JOBS > $SEQUENTIAL ]]; then + if [[ $JOBS -gt $SEQUENTIAL ]]; then make -j"$JOBS" "$@" $VERBOSITY else make "$@" $VERBOSITY @@ -272,7 +272,7 @@ parse_command_line_options() (--build-secp256k1) BUILD_SECP256K1="yes";; # Unique script options. - (--build-dir=*) BUILD_DIR="${OPTION#*=}";; + (--build-dir=*) BUILD_SRC_DIR="${OPTION#*=}";; # Handle ndebug declarations due to disabled argument passthrough (--enable-ndebug) ENABLE_NDEBUG="yes";; @@ -326,11 +326,6 @@ set_os_specific_compiler_settings() else # Linux STDLIB="stdc++" fi - - if [[ ($OS == Darwin) && ($CC == clang*) ]]; then - CFLAGS="${CFLAGS} -DBOOST_NO_CXX98_FUNCTION_BASE" - CXXFLAGS="${CXXFLAGS} -DBOOST_NO_CXX98_FUNCTION_BASE" - fi } link_to_standard_library() @@ -481,7 +476,7 @@ display_configuration() display_message "BUILD_BOOST : $BUILD_BOOST" display_message "BUILD_SECP256K1 : $BUILD_SECP256K1" display_message "BOOST_ROOT : $BOOST_ROOT" - display_message "BUILD_DIR : $BUILD_DIR" + display_message "BUILD_SRC_DIR : $BUILD_SRC_DIR" display_message "CUMULATIVE_FILTERED_ARGS : $CUMULATIVE_FILTERED_ARGS" display_message "CUMULATIVE_FILTERED_ARGS_CMAKE : $CUMULATIVE_FILTERED_ARGS_CMAKE" display_message "PREFIX : $PREFIX" @@ -1073,10 +1068,10 @@ BITCOIN_NODE_OPTIONS=( display_configuration if [[ ! ($CI == true) ]]; then - create_directory "$BUILD_DIR" - push_directory "$BUILD_DIR" + create_directory "$BUILD_SRC_DIR" + push_directory "$BUILD_SRC_DIR" else - push_directory "$BUILD_DIR" + push_directory "$BUILD_SRC_DIR" fi initialize_git diff --git a/install-cmakepresets.sh b/install-cmakepresets.sh index a0cc4b63b..060f97df6 100755 --- a/install-cmakepresets.sh +++ b/install-cmakepresets.sh @@ -66,7 +66,7 @@ fi # The default build directory. #------------------------------------------------------------------------------ -BUILD_DIR="build-libbitcoin-node" +BUILD_SRC_DIR="build-libbitcoin-node" PRESUMED_CI_PROJECT_PATH=$(pwd) @@ -168,13 +168,13 @@ make_jobs() shift 1 VERBOSITY="" - if [[ DISPLAY_VERBOSE ]]; then + if [[ $DISPLAY_VERBOSE ]]; then VERBOSITY="VERBOSE=1" fi SEQUENTIAL=1 # Avoid setting -j1 (causes problems on single threaded systems [TRAVIS]). - if [[ $JOBS > $SEQUENTIAL ]]; then + if [[ $JOBS -gt $SEQUENTIAL ]]; then make -j"$JOBS" "$@" $VERBOSITY else make "$@" $VERBOSITY @@ -279,7 +279,7 @@ parse_command_line_options() (--build-secp256k1) BUILD_SECP256K1="yes";; # Unique script options. - (--build-dir=*) BUILD_DIR="${OPTION#*=}";; + (--build-dir=*) BUILD_SRC_DIR="${OPTION#*=}";; (--preset=*) PRESET_ID="${OPTION#*=}";; # Handle ndebug declarations due to disabled argument passthrough @@ -334,11 +334,6 @@ set_os_specific_compiler_settings() else # Linux STDLIB="stdc++" fi - - if [[ ($OS == Darwin) && ($CC == clang*) ]]; then - CFLAGS="${CFLAGS} -DBOOST_NO_CXX98_FUNCTION_BASE" - CXXFLAGS="${CXXFLAGS} -DBOOST_NO_CXX98_FUNCTION_BASE" - fi } link_to_standard_library() @@ -520,7 +515,7 @@ display_configuration() display_message "BUILD_BOOST : $BUILD_BOOST" display_message "BUILD_SECP256K1 : $BUILD_SECP256K1" display_message "BOOST_ROOT : $BOOST_ROOT" - display_message "BUILD_DIR : $BUILD_DIR" + display_message "BUILD_SRC_DIR : $BUILD_SRC_DIR" display_message "PRESET_ID : $PRESET_ID" display_message "CUMULATIVE_FILTERED_ARGS : $CUMULATIVE_FILTERED_ARGS" display_message "CUMULATIVE_FILTERED_ARGS_CMAKE : $CUMULATIVE_FILTERED_ARGS_CMAKE" @@ -1121,10 +1116,10 @@ BITCOIN_NODE_OPTIONS=( display_configuration if [[ ! ($CI == true) ]]; then - create_directory "$BUILD_DIR" - push_directory "$BUILD_DIR" + create_directory "$BUILD_SRC_DIR" + push_directory "$BUILD_SRC_DIR" else - push_directory "$BUILD_DIR" + push_directory "$BUILD_SRC_DIR" fi initialize_git diff --git a/install.sh b/install.sh index 55284cfa7..e1bc1ca5b 100755 --- a/install.sh +++ b/install.sh @@ -60,7 +60,7 @@ fi # The default build directory. #------------------------------------------------------------------------------ -BUILD_DIR="build-libbitcoin-node" +BUILD_SRC_DIR="build-libbitcoin-node" PRESUMED_CI_PROJECT_PATH=$(pwd) @@ -162,13 +162,13 @@ make_jobs() shift 1 VERBOSITY="" - if [[ DISPLAY_VERBOSE ]]; then + if [[ $DISPLAY_VERBOSE ]]; then VERBOSITY="VERBOSE=1" fi SEQUENTIAL=1 # Avoid setting -j1 (causes problems on single threaded systems [TRAVIS]). - if [[ $JOBS > $SEQUENTIAL ]]; then + if [[ $JOBS -gt $SEQUENTIAL ]]; then make -j"$JOBS" "$@" $VERBOSITY else make "$@" $VERBOSITY @@ -272,7 +272,7 @@ parse_command_line_options() (--build-secp256k1) BUILD_SECP256K1="yes";; # Unique script options. - (--build-dir=*) BUILD_DIR="${OPTION#*=}";; + (--build-dir=*) BUILD_SRC_DIR="${OPTION#*=}";; esac done } @@ -321,11 +321,6 @@ set_os_specific_compiler_settings() else # Linux STDLIB="stdc++" fi - - if [[ ($OS == Darwin) && ($CC == clang*) ]]; then - CFLAGS="${CFLAGS} -DBOOST_NO_CXX98_FUNCTION_BASE" - CXXFLAGS="${CXXFLAGS} -DBOOST_NO_CXX98_FUNCTION_BASE" - fi } link_to_standard_library() @@ -426,7 +421,7 @@ display_configuration() display_message "BUILD_BOOST : $BUILD_BOOST" display_message "BUILD_SECP256K1 : $BUILD_SECP256K1" display_message "BOOST_ROOT : $BOOST_ROOT" - display_message "BUILD_DIR : $BUILD_DIR" + display_message "BUILD_SRC_DIR : $BUILD_SRC_DIR" display_message "PREFIX : $PREFIX" display_message "DISABLE_SHARED : $DISABLE_SHARED" display_message "DISABLE_STATIC : $DISABLE_STATIC" @@ -947,10 +942,10 @@ BITCOIN_NODE_OPTIONS=( display_configuration if [[ ! ($CI == true) ]]; then - create_directory "$BUILD_DIR" - push_directory "$BUILD_DIR" + create_directory "$BUILD_SRC_DIR" + push_directory "$BUILD_SRC_DIR" else - push_directory "$BUILD_DIR" + push_directory "$BUILD_SRC_DIR" fi initialize_git diff --git a/src/full_node.cpp b/src/full_node.cpp index fd0bfc3db..c1756d8a5 100644 --- a/src/full_node.cpp +++ b/src/full_node.cpp @@ -23,7 +23,8 @@ #include #include #include -#include +////#include +////#include namespace libbitcoin { namespace node { @@ -419,17 +420,17 @@ network::memory& full_node::get_memory() NOEXCEPT network::session_manual::ptr full_node::attach_manual_session() NOEXCEPT { - return net::attach(*this); + return attach(*this); } network::session_inbound::ptr full_node::attach_inbound_session() NOEXCEPT { - return net::attach(*this); + return attach(*this); } network::session_outbound::ptr full_node::attach_outbound_session() NOEXCEPT { - return net::attach(*this); + return attach(*this); } BC_POP_WARNING() diff --git a/src/protocols/protocol_explore.cpp b/src/protocols/protocol_explore.cpp new file mode 100644 index 000000000..7d1554fd4 --- /dev/null +++ b/src/protocols/protocol_explore.cpp @@ -0,0 +1,94 @@ +/** + * Copyright (c) 2011-2025 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +#include + +#include +#include + +namespace libbitcoin { +namespace node { + +#define CLASS protocol_explore + +using namespace system; +using namespace network::http; +using namespace std::placeholders; + +// Handle get method. +// ---------------------------------------------------------------------------- + +// fields[], request->target(), file.is_open() are undeclared noexcept. +BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT) + +void protocol_explore::handle_receive_get(const code& ec, + const method::get& request) NOEXCEPT +{ + BC_ASSERT_MSG(stranded(), "strand"); + + if (stopped(ec)) + return; + + // Enforce http origin policy (requires configured hosts). + if (!is_allowed_origin((*request)[field::origin], request->version())) + { + send_forbidden(*request); + return; + } + + // Enforce http host header (if any hosts are configured). + if (!is_allowed_host((*request)[field::host], request->version())) + { + send_bad_host(*request); + return; + } + + // Empty path implies malformed target (terminal). + auto path = to_local_path(request->target()); + if (path.empty()) + { + send_bad_target(*request); + return; + } + + if (!path.has_extension()) + { + // Empty path implies default page is invalid or not configured. + path = to_local_path(); + if (path.empty()) + { + send_not_implemented(*request); + return; + } + } + + // Not open implies file not found (non-terminal). + auto file = get_file_body(path); + if (!file.is_open()) + { + send_not_found(*request); + return; + } + + send_file(*request, std::move(file), file_mime_type(path)); +} + +BC_POP_WARNING() + +} // namespace node +} // namespace libbitcoin