def talkToClaymore(ip, port, password):
#Iniate socket and connect to Claymore
claymore_connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
claymore_connection.connect((ip, port))
#Send request to Claymore
request_data = '{"id":0,"jsonrpc":"2.0","method":"miner_getstat1","psw":"%s"}' % password
claymore_connection.send(request_data.encode('utf-8'))
#Receive Claymore data
claymore_response = claymore_connection.recv(2048)
claymore_connection.close()
claymore = json.loads(claymore_response)['result']
#Parse data
gpus = []
for x in range(0, int(len(claymore[6].split(';')) / 2)):
gpus.append({
#Find the hashrate of the GPU and convert to megahash
'hashrate': int(claymore[3].split(';')[x]) / 1000,
#Find GPU temperature. We multiply the index by 2 to get every second value.
'temperature': claymore[6].split(';')[int(x) * 2],
#Find GPU fan speed. We multiply the index by 2 and plus 1 to get the value right after the temperature value
'fanSpeed': claymore[6].split(';')[int(x) * 2 + 1]
})
claymore_data = {
#Find Claymore version
'version': claymore[0],
#Returns uptime in *minutes*
'uptime': claymore[1],
#Return total hashrate, converted to megahash
'totalHashrate': int(claymore[2].split(';')[0]) / 1000,
#Returns total shares completed
'totalEthShares': claymore[2].split(';')[1],
#Returns rejected shares
'totalEthRejectedShares': claymore[2].split(';')[2],
#Returns GPU count using temperature and fan speed
'gpuCount': int(len(claymore[6].split(';')) / 2),
#Detailed statistics for each GPU
'gpus': gpus,
#Returns current pool
'pool': claymore[7]
}
return claymore_data