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
8 changes: 4 additions & 4 deletions include/bitcoin/network/channels/channel_http.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
namespace libbitcoin {
namespace network {

/// Half-duplex reading of http-request and sending of http-response.
/// Half-duplex reading/writing of http-request/response.
class BCT_API channel_http
: public channel
{
Expand All @@ -43,7 +43,7 @@ class BCT_API channel_http
using interface = rpc::interface::http;
using dispatcher = rpc::dispatcher<interface>;

/// Subscribe to request from peer (requires strand).
/// Subscribe to request from client (requires strand).
/// Event handler is always invoked on the channel strand.
template <class Request>
inline void subscribe(auto&& handler) NOEXCEPT
Expand Down Expand Up @@ -71,7 +71,7 @@ class BCT_API channel_http
/// Must call after successful message handling if no stop.
virtual void receive() NOEXCEPT;

/// Serialize and write http response to peer (requires strand).
/// Serialize and write http response to client (requires strand).
/// Completion handler is always invoked on the channel strand.
virtual void send(http::response&& response,
result_handler&& handler) NOEXCEPT;
Expand All @@ -89,7 +89,7 @@ class BCT_API channel_http
/// Size and assign response_buffer_ if value type is json or json-rpc.
virtual void assign_json_buffer(http::response& response) NOEXCEPT;

// Handlers.
/// Handlers.
virtual void handle_receive(const code& ec, size_t bytes,
const http::request_cptr& request) NOEXCEPT;
virtual void handle_send(const code& ec, size_t bytes, http::response_ptr&,
Expand Down
12 changes: 11 additions & 1 deletion include/bitcoin/network/channels/channel_rpc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
namespace libbitcoin {
namespace network {

/// rpc over tcp channel.
/// Read rpc-request and send rpc-response.
class BCT_API channel_rpc
: public channel
{
Expand All @@ -41,6 +41,16 @@ class BCT_API channel_rpc
: channel(log, socket, identifier, settings, options)
{
}

/// Resume reading from the socket (requires strand).
void resume() NOEXCEPT override;

/// Must call after successful message handling if no stop.
virtual void receive() NOEXCEPT;

/// Serialize and write rpc response to client (requires strand).
/// Completion handler is always invoked on the channel strand.
virtual void send() NOEXCEPT;
};

} // namespace network
Expand Down
4 changes: 2 additions & 2 deletions include/bitcoin/network/protocols/protocol_http.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ class BCT_API protocol_http
using channel_t = channel_http;
using options_t = channel_t::options_t;

void start() NOEXCEPT override;

protected:
protocol_http(const session::ptr& session, const channel::ptr& channel,
const options_t& options) NOEXCEPT;

void start() NOEXCEPT override;

DECLARE_SEND();
DECLARE_SUBSCRIBE_CHANNEL();

Expand Down
17 changes: 17 additions & 0 deletions src/channels/channel_rpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,22 @@
namespace libbitcoin {
namespace network {

void channel_rpc::resume() NOEXCEPT
{
BC_ASSERT(stranded());
channel::resume();
receive();
}

void channel_rpc::receive() NOEXCEPT
{
BC_ASSERT(stranded());
}

void channel_rpc::send() NOEXCEPT
{
BC_ASSERT(stranded());
}

} // namespace network
} // namespace libbitcoin
1 change: 1 addition & 0 deletions src/protocols/protocol_http.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ protocol_http::protocol_http(const session::ptr& session,
// Start.
// ----------------------------------------------------------------------------

// public
void protocol_http::start() NOEXCEPT
{
BC_ASSERT(stranded());
Expand Down
Loading