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
1 change: 1 addition & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ include_bitcoin_node_channels_HEADERS = \
include/bitcoin/node/channels/channel_http.hpp \
include/bitcoin/node/channels/channel_peer.hpp \
include/bitcoin/node/channels/channel_tcp.hpp \
include/bitcoin/node/channels/channel_websocket.hpp \
include/bitcoin/node/channels/channels.hpp

include_bitcoin_node_chasersdir = ${includedir}/bitcoin/node/chasers
Expand Down
1 change: 1 addition & 0 deletions builds/msvc/vs2022/libbitcoin-node/libbitcoin-node.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@
<ClInclude Include="..\..\..\..\include\bitcoin\node\channels\channel_http.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\node\channels\channel_peer.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\node\channels\channel_tcp.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\node\channels\channel_websocket.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\node\channels\channels.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\node\chase.hpp" />
<ClInclude Include="..\..\..\..\include\bitcoin\node\chasers\chaser.hpp" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@
<ClInclude Include="..\..\..\..\include\bitcoin\node\channels\channel_tcp.hpp">
<Filter>include\bitcoin\node\channels</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\include\bitcoin\node\channels\channel_websocket.hpp">
<Filter>include\bitcoin\node\channels</Filter>
</ClInclude>
<ClInclude Include="..\..\..\..\include\bitcoin\node\channels\channels.hpp">
<Filter>include\bitcoin\node\channels</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 @@ -31,6 +31,7 @@
#include <bitcoin/node/channels/channel_http.hpp>
#include <bitcoin/node/channels/channel_peer.hpp>
#include <bitcoin/node/channels/channel_tcp.hpp>
#include <bitcoin/node/channels/channel_websocket.hpp>
#include <bitcoin/node/channels/channels.hpp>
#include <bitcoin/node/chasers/chaser.hpp>
#include <bitcoin/node/chasers/chaser_block.hpp>
Expand Down
53 changes: 53 additions & 0 deletions include/bitcoin/node/channels/channel_websocket.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* 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_CHANNELS_CHANNEL_WEBSOCKET_HPP
#define LIBBITCOIN_NODE_CHANNELS_CHANNEL_WEBSOCKET_HPP

#include <memory>
#include <bitcoin/node/channels/channel.hpp>
#include <bitcoin/node/configuration.hpp>
#include <bitcoin/node/define.hpp>

namespace libbitcoin {
namespace node {

/// Abstract base websocket channel state for the node.
class BCN_API channel_websocket
: public network::channel_websocket,
public node::channel
{
public:
typedef std::shared_ptr<node::channel_websocket> ptr;
using options_t = network::channel_websocket::options_t;

channel_websocket(const network::logger& log,
const network::socket::ptr& socket,
const node::configuration& config, uint64_t identifier=zero,
const options_t& options={}) NOEXCEPT
: network::channel_websocket(log, socket, config.network, identifier,
options),
node::channel(log, socket, config, identifier)
{
}
};

} // namespace node
} // namespace libbitcoin

#endif
2 changes: 1 addition & 1 deletion include/bitcoin/node/channels/channels.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <bitcoin/node/channels/channel_peer.hpp>
#include <bitcoin/node/channels/channel_tcp.hpp>
#include <bitcoin/node/channels/channel_http.hpp>
// add channel_websocket to network and derive here
#include <bitcoin/node/channels/channel_websocket.hpp>

#endif

5 changes: 5 additions & 0 deletions include/bitcoin/node/protocols/protocol_websocket.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,18 @@
namespace libbitcoin {
namespace node {

// TODO: maybe make this an intermediate base class for websockets.
// TODO: and then create a distinct concrete class for deployment.
class BCN_API protocol_websocket
: public node::protocol_http,
protected network::tracker<protocol_websocket>
{
public:
typedef std::shared_ptr<protocol_websocket> ptr;

// Replace base class channel_t (node::channel_http).
using channel_t = node::channel_websocket;

protocol_websocket(const auto& session,
const network::channel::ptr& channel,
const options_t& options) NOEXCEPT
Expand Down
2 changes: 1 addition & 1 deletion include/bitcoin/node/settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class BCN_API settings
server::settings::html_server explore{ "explore" };

/// native websocket query interface (http/s->tcp/s, json, handshake)
network::settings::webs_server websocket{ "websocket" };
network::settings::websocket_server websocket{ "websocket" };

/// bitcoind compat interface (http/s, stateless json-rpc-v2)
network::settings::http_server bitcoind{ "bitcoind" };
Expand Down
Loading