Skip to content

Commit

Permalink
implement client.reconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
mbevand committed Nov 10, 2016
1 parent ddb3ec7 commit 4a56d09
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
solutions on-device
* Optimization: reduce size of collisions[] array; +7% speed increase measured
on RX 480 and R9 Nano using AMDGPU-PRO 16.40
* Implement stratum method client.reconnect
* Avoid segfault when encountering an out-of-range input
* For simplicity `-i <header>` now only accepts 140-byte headers
* Update README.md with Nvidia performance numbers
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ I would like to thank these persons for their contributions to SILENTARMY,
in alphabetical order:
* lhl
* nerdralph
* poiuty
* solardiz

# License
Expand Down
7 changes: 6 additions & 1 deletion silentarmy
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ class Silentarmy:
self.solver_procs = {}
self.solver_binary = os.path.join(sys.path[0], 'sa-solver')
# Stratum-related attributes
self.st_transport = None
self.st_conn_attempt = 0
self.st_had_job = False
self.st_protocol = StratumClientProtocol(self)
Expand Down Expand Up @@ -194,7 +195,7 @@ class Silentarmy:
coro = self.loop.create_connection(lambda: self.st_protocol,
self.host, self.port)
try:
yield from coro
(self.st_transport, _) = yield from coro
except Exception as e:
print("Stratum: error connecting: %s" % e)
my_ensure_future(self.reconnect())
Expand Down Expand Up @@ -506,6 +507,10 @@ class Silentarmy:
# hashReserved, nTime, nBits, clean_jobs ]
self.set_new_job(*msg['params'][:8])
self.update_mining_job()
elif msg['method'] == 'client.reconnect':
print("Stratum server forcing a reconnection")
self.st_transport.close()
# reconnection will happen automatically in connection_lost()
else:
raise Exception('Unimplemented method: %s' % msg['method'])
else:
Expand Down

0 comments on commit 4a56d09

Please sign in to comment.