1818 */
1919#include < bitcoin/node/protocols/protocol_stratum_v1.hpp>
2020
21+ #include < bitcoin/node/define.hpp>
22+ #include < bitcoin/node/interfaces/interfaces.hpp>
2123#include < bitcoin/node/protocols/protocol_rpc.hpp>
2224
2325namespace libbitcoin {
2426namespace node {
2527
2628#define CLASS protocol_stratum_v1
2729
30+ using namespace interface ;
2831using namespace std ::placeholders;
2932
3033BC_PUSH_WARNING (NO_THROW_IN_NOEXCEPT)
@@ -41,18 +44,128 @@ void protocol_stratum_v1::start() NOEXCEPT
4144 if (started ())
4245 return ;
4346
47+ // Client requests.
48+ SUBSCRIBE_RPC (handle_mining_subscribe, _1, _2, _3, _4);
49+ SUBSCRIBE_RPC (handle_mining_authorize, _1, _2, _3, _4);
50+ SUBSCRIBE_RPC (handle_mining_submit, _1, _2, _3, _4, _5, _6, _7);
4451 SUBSCRIBE_RPC (handle_mining_extranonce_subscribe, _1, _2);
52+ SUBSCRIBE_RPC (handle_mining_extranonce_unsubscribe, _1, _2, _3);
53+
54+ // Server notifications.
55+ SUBSCRIBE_RPC (handle_mining_configure, _1, _2, _3);
56+ SUBSCRIBE_RPC (handle_mining_set_difficulty, _1, _2, _3);
57+ SUBSCRIBE_RPC (handle_mining_notify, _1, _2, _3, _4, _5, _6, _7, _8, _9,
58+ _10, _11, _12, _12);
59+ SUBSCRIBE_RPC (handle_client_reconnect, _1, _2, _3, _4, _5);
60+ SUBSCRIBE_RPC (handle_client_hello, _1, _2, _3);
61+ SUBSCRIBE_RPC (handle_client_rejected, _1, _2, _3, _4);
4562 node::protocol_rpc<rpc_interface>::start ();
4663}
4764
48- // Handlers.
65+ // Handlers (client requests) .
4966// ----------------------------------------------------------------------------
5067
68+ bool protocol_stratum_v1::handle_mining_subscribe (const code& ec,
69+ rpc_interface::mining_subscribe, const std::string& ,
70+ double ) NOEXCEPT
71+ {
72+ if (stopped (ec)) return false ;
73+ send_code (error::not_implemented);
74+ return true ;
75+ }
76+
77+ bool protocol_stratum_v1::handle_mining_authorize (const code& ec,
78+ rpc_interface::mining_authorize, const std::string& ,
79+ const std::string& ) NOEXCEPT
80+ {
81+ if (stopped (ec)) return false ;
82+ send_code (error::not_implemented);
83+ return true ;
84+ }
85+
86+ bool protocol_stratum_v1::handle_mining_submit (const code& ec,
87+ rpc_interface::mining_submit, const std::string& ,
88+ const std::string& , const std::string& ,
89+ double , const std::string& ) NOEXCEPT
90+ {
91+ if (stopped (ec)) return false ;
92+ send_code (error::not_implemented);
93+ return true ;
94+ }
95+
5196bool protocol_stratum_v1::handle_mining_extranonce_subscribe (const code& ec,
5297 rpc_interface::mining_extranonce_subscribe) NOEXCEPT
5398{
54- // TODO:
55- return !ec;
99+ if (stopped (ec)) return false ;
100+ send_code (error::not_implemented);
101+ return true ;
102+ }
103+
104+ bool protocol_stratum_v1::handle_mining_extranonce_unsubscribe (const code& ec,
105+ rpc_interface::mining_extranonce_unsubscribe, double ) NOEXCEPT
106+ {
107+ if (stopped (ec)) return false ;
108+ send_code (error::not_implemented);
109+ return true ;
110+ }
111+
112+ // Handlers (server notifications).
113+ // ----------------------------------------------------------------------------
114+
115+ bool protocol_stratum_v1::handle_mining_configure (const code& ec,
116+ rpc_interface::mining_configure,
117+ const interface::object_t & ) NOEXCEPT
118+ {
119+ if (stopped (ec)) return false ;
120+ send_code (error::not_implemented);
121+ return true ;
122+ }
123+
124+ bool protocol_stratum_v1::handle_mining_set_difficulty (const code& ec,
125+ rpc_interface::mining_set_difficulty, double ) NOEXCEPT
126+ {
127+ if (stopped (ec)) return false ;
128+ send_code (error::not_implemented);
129+ return true ;
130+ }
131+
132+ bool protocol_stratum_v1::handle_mining_notify (const code& ec,
133+ rpc_interface::mining_notify, const std::string& ,
134+ const std::string& , const std::string& ,
135+ const std::string& , const interface::array_t & ,
136+ double , double , double , bool ,
137+ bool , bool ) NOEXCEPT
138+ {
139+ if (stopped (ec)) return false ;
140+ send_code (error::not_implemented);
141+ return true ;
142+ }
143+
144+ bool protocol_stratum_v1::handle_client_reconnect (const code& ec,
145+ rpc_interface::client_reconnect, const std::string& , double ,
146+ double ) NOEXCEPT
147+ {
148+ if (stopped (ec)) return false ;
149+ send_code (error::not_implemented);
150+ return true ;
151+ }
152+
153+ bool protocol_stratum_v1::handle_client_hello (const code& ec,
154+ rpc_interface::client_hello,
155+ const interface::object_t & ) NOEXCEPT
156+ {
157+ if (stopped (ec)) return false ;
158+ send_code (error::not_implemented);
159+ return true ;
160+ }
161+
162+ bool protocol_stratum_v1::handle_client_rejected (const code& ec,
163+ rpc_interface::client_rejected, const std::string& ,
164+ const std::string& ) NOEXCEPT
165+ {
166+ if (stopped (ec)) return false ;
167+ send_code (error::not_implemented);
168+ return true ;
56169}
57170
58171BC_POP_WARNING ()
0 commit comments