Skip to content

Commit 5371e21

Browse files
authored
Merge pull request #682 from evoskuil/master
Stub in channel_rpc methods.
2 parents 2bed422 + 84f62d7 commit 5371e21

File tree

5 files changed

+35
-7
lines changed

5 files changed

+35
-7
lines changed

include/bitcoin/network/channels/channel_http.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
namespace libbitcoin {
3434
namespace network {
3535

36-
/// Half-duplex reading of http-request and sending of http-response.
36+
/// Half-duplex reading/writing of http-request/response.
3737
class BCT_API channel_http
3838
: public channel
3939
{
@@ -43,7 +43,7 @@ class BCT_API channel_http
4343
using interface = rpc::interface::http;
4444
using dispatcher = rpc::dispatcher<interface>;
4545

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

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

92-
// Handlers.
92+
/// Handlers.
9393
virtual void handle_receive(const code& ec, size_t bytes,
9494
const http::request_cptr& request) NOEXCEPT;
9595
virtual void handle_send(const code& ec, size_t bytes, http::response_ptr&,

include/bitcoin/network/channels/channel_rpc.hpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
namespace libbitcoin {
2929
namespace network {
3030

31-
/// rpc over tcp channel.
31+
/// Read rpc-request and send rpc-response.
3232
class BCT_API channel_rpc
3333
: public channel
3434
{
@@ -41,6 +41,16 @@ class BCT_API channel_rpc
4141
: channel(log, socket, identifier, settings, options)
4242
{
4343
}
44+
45+
/// Resume reading from the socket (requires strand).
46+
void resume() NOEXCEPT override;
47+
48+
/// Must call after successful message handling if no stop.
49+
virtual void receive() NOEXCEPT;
50+
51+
/// Serialize and write rpc response to client (requires strand).
52+
/// Completion handler is always invoked on the channel strand.
53+
virtual void send() NOEXCEPT;
4454
};
4555

4656
} // namespace network

include/bitcoin/network/protocols/protocol_http.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ class BCT_API protocol_http
4747
using channel_t = channel_http;
4848
using options_t = channel_t::options_t;
4949

50+
void start() NOEXCEPT override;
51+
5052
protected:
5153
protocol_http(const session::ptr& session, const channel::ptr& channel,
5254
const options_t& options) NOEXCEPT;
5355

54-
void start() NOEXCEPT override;
55-
5656
DECLARE_SEND();
5757
DECLARE_SUBSCRIBE_CHANNEL();
5858

src/channels/channel_rpc.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,22 @@
2323
namespace libbitcoin {
2424
namespace network {
2525

26+
void channel_rpc::resume() NOEXCEPT
27+
{
28+
BC_ASSERT(stranded());
29+
channel::resume();
30+
receive();
31+
}
32+
33+
void channel_rpc::receive() NOEXCEPT
34+
{
35+
BC_ASSERT(stranded());
36+
}
37+
38+
void channel_rpc::send() NOEXCEPT
39+
{
40+
BC_ASSERT(stranded());
41+
}
42+
2643
} // namespace network
2744
} // namespace libbitcoin

src/protocols/protocol_http.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ protocol_http::protocol_http(const session::ptr& session,
5858
// Start.
5959
// ----------------------------------------------------------------------------
6060

61+
// public
6162
void protocol_http::start() NOEXCEPT
6263
{
6364
BC_ASSERT(stranded());

0 commit comments

Comments
 (0)