Skip to content

Commit 5a79b93

Browse files
committed
Declare send and subscribe on protocol_rpc<>.
1 parent 14bb540 commit 5a79b93

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

include/bitcoin/network/channels/channel_rpc.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class channel_rpc
4040

4141
/// Subscribe to request from client (requires strand).
4242
/// Event handler is always invoked on the channel strand.
43-
template <class Handler>
43+
template <class Void, class Handler>
4444
inline void subscribe(Handler&& handler) NOEXCEPT
4545
{
4646
BC_ASSERT(stranded());

include/bitcoin/network/protocols/protocol.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ class BCT_API protocol
217217
#define DECLARE_SUBSCRIBE_CHANNEL() \
218218
template <class Derived, class Message, typename Method, typename... Args> \
219219
void subscribe_channel(Method&& method, Args&&... args) NOEXCEPT \
220-
{ channel_->subscribe<Message>(BIND_SHARED(method, args)); }
220+
{ channel_->template subscribe<Message>(BIND_SHARED(method, args)); }
221221

222222
#define SEND(message, method, ...) \
223223
send<CLASS>(message, &CLASS::method, __VA_ARGS__)

include/bitcoin/network/protocols/protocol_rpc.hpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,18 @@ class protocol_rpc
3939
protected:
4040
inline protocol_rpc(const session::ptr& session,
4141
const channel::ptr& channel, const options_t&) NOEXCEPT
42-
: protocol(session, channel)
42+
: protocol(session, channel),
43+
channel_(std::dynamic_pointer_cast<channel_t>(channel))
4344
{
4445
}
46+
47+
DECLARE_SEND()
48+
DECLARE_SUBSCRIBE_CHANNEL()
49+
50+
private:
51+
// This is mostly thread safe, and used in a thread safe manner.
52+
// pause/resume/paused/attach not invoked, setters limited to handshake.
53+
const channel_t::ptr channel_;
4554
};
4655

4756
} // namespace network

0 commit comments

Comments
 (0)