Added a try except
I added a try: except that reconnects if network breaks
This commit is contained in:
parent
74559a15a8
commit
6027b4a6b2
|
@ -1,7 +1,7 @@
|
||||||
import socket, hashlib
|
import socket, hashlib
|
||||||
# Global variables
|
# Global variables
|
||||||
soc = socket.socket()
|
soc = socket.socket()
|
||||||
username = "user" # Edit this to your username, mind the quotes
|
username = "Yanis" # 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
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ while True:
|
||||||
print("Server is on version", server_version)
|
print("Server is on version", server_version)
|
||||||
# Mining section
|
# Mining section
|
||||||
while True:
|
while True:
|
||||||
|
try:
|
||||||
soc.send(bytes("JOB," + str(username) + ",ESP32", encoding="utf8")) # Send job request
|
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
|
||||||
|
@ -32,4 +33,7 @@ while True:
|
||||||
) # 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:
|
||||||
|
soc.close()
|
||||||
|
soc = socket.socket()
|
||||||
|
soc.connect((str(pool_address), int(pool_port))) # Connect to the server
|
||||||
|
|
Loading…
Reference in New Issue