我在比特币或莱特币中找到了很多关于 Getwork 的资源。它需要我在我的计算机上运行代理,以便矿工软件可以从矿池中获取工作。
我想知道如何直接访问像
stratum+tcp://
这样的主机?
是否有您知道的任何协议或示例代码 - 最好是“C”或 Python 语言?
正在考虑同样的事情,我想到目前为止我已经对 stratum+tcp 协议进行了逆向工程......
import socket
import json
# Stratum server details
host = 'solo.ckpool.org'
port = 3333
username = '199QiJj1miojVSAop7gpAamscHd77r12ET'
password = 'x'
# Create a TCP/IP socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
# Connect to the Stratum server
sock.connect((host, port))
# Send subscription request (mining.subscribe)
subscribe_message = {
"id": 1,
"method": "mining.subscribe",
"params": []
}
print(f"Sending subscribe message: {subscribe_message}")
sock.sendall((json.dumps(subscribe_message) + '\n').encode('utf-8'))
# Send authorization request (mining.authorize)
authorize_message = {
"id": 2,
"method": "mining.authorize",
"params": [username, password]
}
print(f"Sending authorize message: {authorize_message}")
sock.sendall((json.dumps(authorize_message) + '\n').encode('utf-8'))
# Receive and print server responses
while True:
data = sock.recv(1024).decode('utf-8') # Receive data from the server
if data:
for message in data.split('\n'):
if message: # Ignore empty messages
try:
json_message = json.loads(message)
print(json.dumps(json_message, indent=4)) # Pretty print JSON
except json.JSONDecodeError:
print(f"Failed to decode message: {message}")
except Exception as e:
print(f"An error occurred: {e}")
finally:
sock.close() # Close the connection
我仍然有一个问题是/必须弄清楚是一些参数(尚未全部编码),但它可能会帮助你作为一个开始。
不直接,但很有趣。测试 >> miningcore >> 让你成为阶层...