mirror of
https://github.com/SChernykh/p2pool.git
synced 2024-12-22 11:29:23 +00:00
Added a fake merge mining node
This commit is contained in:
parent
e6b8292d5b
commit
d1fee33482
3 changed files with 34 additions and 2 deletions
|
@ -73,6 +73,7 @@ MergeMiningClient::MergeMiningClient(p2pool* pool, const std::string& host, cons
|
|||
uv_loop_close(&m_loop);
|
||||
throw std::exception();
|
||||
}
|
||||
m_timer.data = this;
|
||||
|
||||
err = uv_thread_create(&m_loopThread, loop, this);
|
||||
if (err) {
|
||||
|
|
|
@ -123,9 +123,10 @@ static FORCEINLINE bool from_hex(const char* s, size_t len, std::vector<uint8_t>
|
|||
return false;
|
||||
}
|
||||
|
||||
std::vector<uint8_t> result(len / 2);
|
||||
len /= 2;
|
||||
std::vector<uint8_t> result(len);
|
||||
|
||||
for (uint32_t i = 0; i < HASH_SIZE; ++i) {
|
||||
for (uint32_t i = 0; i < len; ++i) {
|
||||
uint8_t d[2];
|
||||
if (!from_hex(s[i * 2], d[0]) || !from_hex(s[i * 2 + 1], d[1])) {
|
||||
return false;
|
||||
|
|
30
tests/src/mm_server.py
Normal file
30
tests/src/mm_server.py
Normal file
|
@ -0,0 +1,30 @@
|
|||
import http.server
|
||||
import socketserver
|
||||
import json
|
||||
|
||||
class Server(http.server.BaseHTTPRequestHandler):
|
||||
def do_POST(self):
|
||||
length = int(self.headers['content-length'])
|
||||
request = self.rfile.read(length)
|
||||
print(request.decode('utf-8'))
|
||||
request = json.loads(request)
|
||||
|
||||
self.send_response(200)
|
||||
self.send_header('Content-type', 'application/json')
|
||||
self.end_headers()
|
||||
|
||||
response = {'jsonrpc':'2.0','id':'0'}
|
||||
|
||||
if request['method'] == 'merge_mining_get_chain_id':
|
||||
response['result'] = {'chain_id':'0f28c4960d96647e77e7ab6d13b85bd16c7ca56f45df802cdc763a5e5c0c7863'}
|
||||
elif request['method'] == 'merge_mining_get_job':
|
||||
response['result'] = {'aux_blob':'4c6f72656d20697073756d','aux_diff':123456,'aux_hash':'f6952d6eef555ddd87aca66e56b91530222d6e318414816f3ba7cf5bf694bf0f'}
|
||||
elif request['method'] == 'merge_mining_submit_solution':
|
||||
response['result'] = {'status':'accepted'}
|
||||
|
||||
response = json.dumps(response);
|
||||
print(response)
|
||||
self.wfile.write(response.encode('utf-8'))
|
||||
|
||||
httpd = socketserver.TCPServer(('', 8000), Server)
|
||||
httpd.serve_forever()
|
Loading…
Reference in a new issue