Skip to content

Commit 50bf54d

Browse files
committed
Stub in stratum_v1 interface.
1 parent 961e391 commit 50bf54d

File tree

2 files changed

+151
-4
lines changed

2 files changed

+151
-4
lines changed

include/bitcoin/node/protocols/protocol_stratum_v1.hpp

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,43 @@ class BCN_API protocol_stratum_v1
4646
void start() NOEXCEPT override;
4747

4848
protected:
49-
/// Handlers.
49+
/// Handlers (client requests).
50+
bool handle_mining_subscribe(const code& ec,
51+
rpc_interface::mining_subscribe, const std::string& user_agent,
52+
double extranonce1_size) NOEXCEPT;
53+
bool handle_mining_authorize(const code& ec,
54+
rpc_interface::mining_authorize, const std::string& username,
55+
const std::string& password) NOEXCEPT;
56+
bool handle_mining_submit(const code& ec,
57+
rpc_interface::mining_submit, const std::string& worker_name,
58+
const std::string& job_id, const std::string& extranonce2,
59+
double ntime, const std::string& nonce) NOEXCEPT;
5060
bool handle_mining_extranonce_subscribe(const code& ec,
5161
rpc_interface::mining_extranonce_subscribe) NOEXCEPT;
62+
bool handle_mining_extranonce_unsubscribe(const code& ec,
63+
rpc_interface::mining_extranonce_unsubscribe, double id) NOEXCEPT;
64+
65+
/// Handlers (server notifications).
66+
bool handle_mining_configure(const code& ec,
67+
rpc_interface::mining_configure,
68+
const interface::object_t& extensions) NOEXCEPT;
69+
bool handle_mining_set_difficulty(const code& ec,
70+
rpc_interface::mining_set_difficulty, double difficulty) NOEXCEPT;
71+
bool handle_mining_notify(const code& ec,
72+
rpc_interface::mining_notify, const std::string& job_id,
73+
const std::string& prevhash, const std::string& coinb1,
74+
const std::string& coinb2, const interface::array_t& merkle_branch,
75+
double version, double nbits, double ntime, bool clean_jobs,
76+
bool hash1, bool hash2) NOEXCEPT;
77+
bool handle_client_reconnect(const code& ec,
78+
rpc_interface::client_reconnect, const std::string& url, double port,
79+
double id) NOEXCEPT;
80+
bool handle_client_hello(const code& ec,
81+
rpc_interface::client_hello,
82+
const interface::object_t& protocol) NOEXCEPT;
83+
bool handle_client_rejected(const code& ec,
84+
rpc_interface::client_rejected, const std::string& job_id,
85+
const std::string& reject_reason) NOEXCEPT;
5286
};
5387

5488
} // namespace node

src/protocols/protocol_stratum_v1.cpp

Lines changed: 116 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,16 @@
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

2325
namespace libbitcoin {
2426
namespace node {
2527

2628
#define CLASS protocol_stratum_v1
2729

30+
using namespace interface;
2831
using namespace std::placeholders;
2932

3033
BC_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+
5196
bool 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

58171
BC_POP_WARNING()

0 commit comments

Comments
 (0)