Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ src_libbitcoin_node_la_SOURCES = \
src/parse/query.cpp \
src/parse/target.cpp \
src/protocols/protocol.cpp \
src/protocols/protocol_bitcoind.cpp \
src/protocols/protocol_block_in_106.cpp \
src/protocols/protocol_block_in_31800.cpp \
src/protocols/protocol_block_out_106.cpp \
Expand Down Expand Up @@ -206,7 +207,8 @@ include_bitcoin_node_interfaces_HEADERS = \
include/bitcoin/node/interfaces/explore.hpp \
include/bitcoin/node/interfaces/interfaces.hpp \
include/bitcoin/node/interfaces/stratum_v1.hpp \
include/bitcoin/node/interfaces/stratum_v2.hpp
include/bitcoin/node/interfaces/stratum_v2.hpp \
include/bitcoin/node/interfaces/types.hpp

include_bitcoin_node_parsedir = ${includedir}/bitcoin/node/parse
include_bitcoin_node_parse_HEADERS = \
Expand Down
1 change: 1 addition & 0 deletions builds/cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ add_library( ${CANONICAL_LIB_NAME}
"../../src/parse/query.cpp"
"../../src/parse/target.cpp"
"../../src/protocols/protocol.cpp"
"../../src/protocols/protocol_bitcoind.cpp"
"../../src/protocols/protocol_block_in_106.cpp"
"../../src/protocols/protocol_block_in_31800.cpp"
"../../src/protocols/protocol_block_out_106.cpp"
Expand Down
2 changes: 2 additions & 0 deletions builds/msvc/vs2022/libbitcoin-node/libbitcoin-node.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
<ClCompile Include="..\..\..\..\src\parse\target.cpp" />
<ClCompile Include="..\..\..\..\src\parser.cpp" />
<ClCompile Include="..\..\..\..\src\protocols\protocol.cpp" />
<ClCompile Include="..\..\..\..\src\protocols\protocol_bitcoind.cpp" />
<ClCompile Include="..\..\..\..\src\protocols\protocol_block_in_106.cpp" />
<ClCompile Include="..\..\..\..\src\protocols\protocol_block_in_31800.cpp" />
<ClCompile Include="..\..\..\..\src\protocols\protocol_block_out_106.cpp" />
Expand Down Expand Up @@ -197,6 +198,7 @@
<ClInclude Include="..\..\..\..\include\bitcoin\node\interfaces\interfaces.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\node\interfaces\stratum_v1.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\node\interfaces\stratum_v2.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\node\interfaces\types.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\node\parse\parse.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\node\parse\query.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\node\parse\target.hpp" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@
<ClCompile Include="..\..\..\..\src\protocols\protocol.cpp">
<Filter>src\protocols</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\src\protocols\protocol_bitcoind.cpp">
<Filter>src\protocols</Filter>
</ClCompile>
<ClCompile Include="..\..\..\..\src\protocols\protocol_block_in_106.cpp">
<Filter>src\protocols</Filter>
</ClCompile>
Expand Down Expand Up @@ -287,6 +290,9 @@
<ClInclude Include="..\..\..\..\include\bitcoin\node\interfaces\stratum_v2.hpp">
<Filter>include\bitcoin\node\interfaces</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\include\bitcoin\node\interfaces\types.hpp">
<Filter>include\bitcoin\node\interfaces</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\include\bitcoin\node\parse\parse.hpp">
<Filter>include\bitcoin\node\parse</Filter>
</ClInclude>
Expand Down
1 change: 1 addition & 0 deletions include/bitcoin/node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
#include <bitcoin/node/interfaces/interfaces.hpp>
#include <bitcoin/node/interfaces/stratum_v1.hpp>
#include <bitcoin/node/interfaces/stratum_v2.hpp>
#include <bitcoin/node/interfaces/types.hpp>
#include <bitcoin/node/parse/parse.hpp>
#include <bitcoin/node/parse/query.hpp>
#include <bitcoin/node/parse/target.hpp>
Expand Down
2 changes: 2 additions & 0 deletions include/bitcoin/node/error.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ enum error_t : uint8_t
invalid_component,
invalid_subcomponent,
extra_segment,

/// server (json-rpc parse codes)
unexpected_parse
};

Expand Down
396 changes: 199 additions & 197 deletions include/bitcoin/node/interfaces/bitcoind.hpp

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions include/bitcoin/node/interfaces/electrum.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#define LIBBITCOIN_NODE_INTERFACES_ELECTRUM_HPP

#include <bitcoin/node/define.hpp>
#include <bitcoin/node/interfaces/types.hpp>

namespace libbitcoin {
namespace node {
Expand Down
1 change: 1 addition & 0 deletions include/bitcoin/node/interfaces/explore.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#define LIBBITCOIN_NODE_INTERFACES_EXPLORE_HPP

#include <bitcoin/node/define.hpp>
#include <bitcoin/node/interfaces/types.hpp>

namespace libbitcoin {
namespace node {
Expand Down
32 changes: 1 addition & 31 deletions include/bitcoin/node/interfaces/interfaces.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,42 +19,12 @@
#ifndef LIBBITCOIN_NODE_INTERFACES_HPP
#define LIBBITCOIN_NODE_INTERFACES_HPP

namespace libbitcoin {
namespace node {
namespace interface {

/// Alias network::rpc names within interface::.

template <text_t Text, typename ...Args>
using method = network::rpc::method<Text, Args...>;
template <auto& Methods, size_t Index>
using method_at = network::rpc::method_at<Methods, Index>;
template <typename Methods, network::rpc::grouping Mode =
network::rpc::grouping::either>
using publish = network::rpc::publish<Methods, Mode>;

template <auto Default>
using optional = network::rpc::optional<Default>;
template <typename Type>
using nullable = network::rpc::nullable<Type>;
using boolean_t = network::rpc::boolean_t;
using string_t = network::rpc::string_t;
using number_t = network::rpc::number_t;
using object_t = network::rpc::object_t;
using array_t = network::rpc::array_t;

namespace empty { constexpr auto array = network::rpc::empty::array; };
namespace empty { constexpr auto object = network::rpc::empty::object; };

} // namespace interface
} // namespace node
} // namespace libbitcoin

#include <bitcoin/node/interfaces/bitcoind.hpp>
#include <bitcoin/node/interfaces/electrum.hpp>
#include <bitcoin/node/interfaces/explore.hpp>
#include <bitcoin/node/interfaces/stratum_v1.hpp>
#include <bitcoin/node/interfaces/stratum_v2.hpp>
#include <bitcoin/node/interfaces/types.hpp>

namespace libbitcoin {
namespace node {
Expand Down
1 change: 1 addition & 0 deletions include/bitcoin/node/interfaces/stratum_v1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#define LIBBITCOIN_NODE_INTERFACES_STRATUM_V1_HPP

#include <bitcoin/node/define.hpp>
#include <bitcoin/node/interfaces/types.hpp>

namespace libbitcoin {
namespace node {
Expand Down
1 change: 1 addition & 0 deletions include/bitcoin/node/interfaces/stratum_v2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#define LIBBITCOIN_NODE_INTERFACES_STRATUM_V2_HPP

#include <bitcoin/node/define.hpp>
#include <bitcoin/node/interfaces/types.hpp>

namespace libbitcoin {
namespace node {
Expand Down
55 changes: 55 additions & 0 deletions include/bitcoin/node/interfaces/types.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* 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 <http://www.gnu.org/licenses/>.
*/
#ifndef LIBBITCOIN_NODE_INTERFACES_TYPES_HPP
#define LIBBITCOIN_NODE_INTERFACES_TYPES_HPP

#include <bitcoin/node/define.hpp>

namespace libbitcoin {
namespace node {
namespace interface {

/// Alias network::rpc names within interface::.

template <text_t Text, typename ...Args>
using method = network::rpc::method<Text, Args...>;
template <auto& Methods, size_t Index>
using method_at = network::rpc::method_at<Methods, Index>;
template <typename Methods, network::rpc::grouping Mode =
network::rpc::grouping::either>
using publish = network::rpc::publish<Methods, Mode>;

template <auto Default>
using optional = network::rpc::optional<Default>;
template <typename Type>
using nullable = network::rpc::nullable<Type>;
using boolean_t = network::rpc::boolean_t;
using string_t = network::rpc::string_t;
using number_t = network::rpc::number_t;
using object_t = network::rpc::object_t;
using array_t = network::rpc::array_t;

namespace empty { constexpr auto array = network::rpc::empty::array; };
namespace empty { constexpr auto object = network::rpc::empty::object; };

} // namespace interface
} // namespace node
} // namespace libbitcoin

#endif
59 changes: 54 additions & 5 deletions include/bitcoin/node/protocols/protocol_bitcoind.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <memory>
#include <bitcoin/node/channels/channels.hpp>
#include <bitcoin/node/define.hpp>
#include <bitcoin/node/interfaces/interfaces.hpp>
#include <bitcoin/node/protocols/protocol_http.hpp>

namespace libbitcoin {
Expand All @@ -33,6 +34,8 @@ class BCN_API protocol_bitcoind
{
public:
typedef std::shared_ptr<protocol_bitcoind> ptr;
using interface = interface::bitcoind;
using dispatcher = network::rpc::dispatcher<interface>;

inline protocol_bitcoind(const auto& session,
const network::channel::ptr& channel,
Expand All @@ -43,18 +46,64 @@ class BCN_API protocol_bitcoind
}

/// Public start is required.
inline void start() NOEXCEPT override
void start() NOEXCEPT override;

protected:
template <class Derived, typename Method, typename... Args>
inline void subscribe(Method&& method, Args&&... args) NOEXCEPT
{
node::protocol_http::start();
dispatcher_.subscribe(BIND_SHARED(method, args));
}

////protected:
//// void handle_receive_get(const code& ec,
//// const network::http::method::get& request) NOEXCEPT override;
/// Dispatch.
void handle_receive_post(const code& ec,
const network::http::method::post::cptr& post) NOEXCEPT override;

/// Handlers.
bool handle_get_best_block_hash(const code& ec,
interface::get_best_block_hash) NOEXCEPT;
bool handle_get_block(const code& ec,
interface::get_block, const std::string&, double) NOEXCEPT;
bool handle_get_block_chain_info(const code& ec,
interface::get_block_chain_info) NOEXCEPT;
bool handle_get_block_count(const code& ec,
interface::get_block_count) NOEXCEPT;
bool handle_get_block_filter(const code& ec,
interface::get_block_filter, const std::string&,
const std::string&) NOEXCEPT;
////bool handle_get_block_hash(const code& ec,
//// interface::get_block_hash, double) NOEXCEPT;
bool handle_get_block_header(const code& ec,
interface::get_block_header, const std::string&, bool) NOEXCEPT;
bool handle_get_block_stats(const code& ec,
interface::get_block_stats, const std::string&,
const network::rpc::array_t&) NOEXCEPT;
bool handle_get_chain_tx_stats(const code& ec,
interface::get_chain_tx_stats, double, const std::string&) NOEXCEPT;
bool handle_get_chain_work(const code& ec,
interface::get_chain_work) NOEXCEPT;
bool handle_get_tx_out(const code& ec,
interface::get_tx_out, const std::string&, double, bool) NOEXCEPT;
bool handle_get_tx_out_set_info(const code& ec,
interface::get_tx_out_set_info) NOEXCEPT;
////bool handle_prune_block_chain(const code& ec,
//// interface::prune_block_chain, double) NOEXCEPT;
bool handle_save_mem_pool(const code& ec,
interface::save_mem_pool) NOEXCEPT;
bool handle_scan_tx_out_set(const code& ec,
interface::scan_tx_out_set, const std::string&,
const network::rpc::array_t&) NOEXCEPT;
bool handle_verify_chain(const code& ec,
interface::verify_chain, double, double) NOEXCEPT;
//bool handle_verify_tx_out_set(const code& ec,
// interface::verify_tx_out_set, const std::string&) NOEXCEPT;

private:
// This is thread safe.
////const options_t& options_;

// This is protected by strand.
dispatcher dispatcher_{};
};

} // namespace node
Expand Down
5 changes: 4 additions & 1 deletion include/bitcoin/node/protocols/protocol_explore.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,11 @@ class BCN_API protocol_explore
database::header_link to_header(const std::optional<uint32_t>& height,
const std::optional<system::hash_cptr>& hash) NOEXCEPT;

dispatcher dispatcher_{};
// This is thread safe.
std::atomic_bool stopping_{};

// This is protected by strand.
dispatcher dispatcher_{};
};

} // namespace node
Expand Down
Loading
Loading