Respawn after connection close
This commit is contained in:
parent
154f38f2c0
commit
bc5a551e71
63
src/main.py
63
src/main.py
|
@ -1,6 +1,5 @@
|
||||||
import socket, hashlib
|
import socket, hashlib
|
||||||
# Global variables
|
# Global variables
|
||||||
soc = socket.socket()
|
|
||||||
username = "user" # Edit this to your username, mind the quotes
|
username = "user" # Edit this to your username, mind the quotes
|
||||||
pool_address = "51.15.127.80"
|
pool_address = "51.15.127.80"
|
||||||
pool_port = 2811
|
pool_port = 2811
|
||||||
|
@ -8,38 +7,34 @@ pool_port = 2811
|
||||||
print("Starting 3DS Miner, you probably will get Output on an error.")
|
print("Starting 3DS Miner, you probably will get Output on an error.")
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
soc.connect((str(pool_address), int(pool_port))) # Connect to the server
|
try:
|
||||||
server_version = soc.recv(3).decode() # Get server version
|
soc = socket.socket()
|
||||||
print("Server is on version", server_version)
|
soc.connect((str(pool_address), int(pool_port))) # Connect to the server
|
||||||
# Mining section
|
server_version = soc.recv(3).decode() # Get server version
|
||||||
while True:
|
print("Server is on version", server_version)
|
||||||
try:
|
# Mining section
|
||||||
soc.send(bytes("JOB," + str(username) + ",ESP32", encoding="utf8")) # Send job request
|
while True:
|
||||||
|
try:
|
||||||
|
soc.send(bytes("JOB," + str(username) + ",ESP32", encoding="utf8")) # Send job request
|
||||||
|
|
||||||
# Don't mind the "ESP32" for now since it is in an early state
|
# Don't mind the "ESP32" for now since it is in an early state
|
||||||
|
|
||||||
job = soc.recv(87).decode() # Get work from pool
|
job = soc.recv(100).decode() # Get work from pool
|
||||||
job = job.split(",") # Split received data to job (job and difficulty)
|
job = job.split(",") # Split received data to job (job and difficulty)
|
||||||
difficulty = job[2]
|
difficulty = job[2]
|
||||||
for result in range(
|
for result in range(
|
||||||
100 * int(difficulty) + 1
|
100 * int(difficulty) + 1
|
||||||
): # Calculate hash with difficulty
|
): # Calculate hash with difficulty
|
||||||
ducos1 = hashlib.sha1(
|
ducos1 = hashlib.sha1(
|
||||||
str(job[0] + str(result)).encode("utf-8")
|
str(job[0] + str(result)).encode("utf-8")
|
||||||
).hexdigest() # Generate hash
|
).hexdigest() # Generate hash
|
||||||
if job[1] == ducos1: # If result is even with job
|
if job[1] == ducos1: # If result is even with job
|
||||||
soc.send(
|
soc.send(
|
||||||
bytes(str(result) + "," + ",3DS Miner unstable)", encoding="utf8")
|
bytes(str(result) + "," + ",3DS Miner unstable)", encoding="utf8")
|
||||||
) # Send result of hashing algorithm to pool
|
) # Send result of hashing algorithm to pool
|
||||||
feedback = soc.recv(1024).decode() # Get feedback about the result
|
feedback = soc.recv(1024).decode() # Get feedback about the result
|
||||||
print(feedback)
|
print(feedback)
|
||||||
except:
|
except:
|
||||||
while True:
|
break
|
||||||
try:
|
except:
|
||||||
soc.close()
|
pass
|
||||||
soc = socket.socket()
|
|
||||||
soc.connect((str(pool_address), int(pool_port))) # Connect to the server
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
break
|
|
||||||
|
|
Loading…
Reference in New Issue