8000 Periodic checks for newer proxy version. · coderlv/stratum-mining-proxy@c8bce1f · GitHub
[go: up one dir, main page]

Skip to content

Commit c8bce1f

Browse files
author
slush
committed
Periodic checks for newer proxy version.
1 parent 903473f commit c8bce1f

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

mining_proxy.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,25 @@ def run_test():
138138
reactor.callLater(1, run_test)
139139
return result
140140

141+
def print_deprecation_warning():
142+
'''Once new version is detected, this method prints deprecation warning every 30 seconds.'''
143+
144+
log.warning("New proxy version available! Please update!")
145+
reactor.callLater(30, print_deprecation_warning)
146+
147+
def test_update():
148+
'''Perform lookup for newer proxy version, on startup and then once a day.
149+
When new version is found, it starts printing warning message and turned off next checks.'''
150+
151+
GIT_URL='https://raw.github.com/slush0/stratum-mining-proxy/master/'
152+
VERSION_FILE = 'mining_libs/version.py'
153+
154+
import urllib2
155+
log.warning("Checking for updates...")
156+
if open(VERSION_FILE).read() != urllib2.urlopen(GIT_URL + VERSION_FILE).read():
157+
print_deprecation_warning()
158+
return # New version already detected, stop periodic checks
159+
reactor.callLater(3600*24, test_update)
141160

142161
@defer.inlineCallbacks
143162
def main(args):
@@ -162,6 +181,8 @@ def main(args):
162181
args.port = new_host[1]
163182

164183
log.warning("Stratum proxy version: %s" % version.VERSION)
184+
# Setup periodic checks for a new version
185+
test_update()
165186

166187
if args.tor:
167188
log.warning("Configuring Tor connection")

0 commit comments

Comments
 (0)
0