SHOW:
|
|
- or go back to the newest paste.
| 1 | import hashlib | |
| 2 | import urllib2 | |
| 3 | import math | |
| 4 | import time | |
| 5 | import timeit | |
| 6 | import sys | |
| 7 | for arg in sys.argv: | |
| 8 | id = arg | |
| 9 | #print("Mining for " + id)
| |
| 10 | print("Mining for " + id)
| |
| 11 | nonce = 0 | |
| 12 | score = 400000000001L | |
| 13 | last = 0 | |
| 14 | total = 0 | |
| 15 | ||
| 16 | def recall(): | |
| 17 | global last | |
| 18 | global target | |
| 19 | tmp = True | |
| 20 | while tmp: | |
| 21 | try: | |
| 22 | resp = urllib2.urlopen('http://65.26.252.225/quest/dia/krist/index.php?getwork')
| |
| 23 | target = int(resp.read()) | |
| 24 | resp.close() | |
| 25 | resp = urllib2.urlopen('http://65.26.252.225/quest/dia/krist/index.php?lastblock')
| |
| 26 | last = resp.read() | |
| 27 | resp.close() | |
| 28 | tmp = False | |
| 29 | except: | |
| 30 | tmp = True | |
| 31 | ||
| 32 | ||
| 33 | ||
| 34 | while True: | |
| 35 | start = timeit.default_timer() | |
| 36 | while True: | |
| 37 | if math.floor(nonce / 250) * 250 == 0: | |
| 38 | recall() | |
| 39 | nonce = nonce + 540 | |
| 40 | m = hashlib.sha256() | |
| 41 | sto = str(nonce) | |
| 42 | slast = str(last) | |
| 43 | thash = id + slast + sto | |
| 44 | m.update(thash) | |
| 45 | toutput = m.hexdigest() | |
| 46 | score = toutput[:12] | |
| 47 | score = int(score, 16) | |
| 48 | if score < target: | |
| 49 | break | |
| 50 | ||
| 51 | stop = timeit.default_timer() | |
| 52 | total += 50 | |
| 53 | resp = urllib2.urlopen('http://65.26.252.225/quest/dia/krist/index.php?getbalance=' + id)
| |
| 54 | a = resp.read() | |
| 55 | resp.close() | |
| 56 | print 'BLOCK! +50 Krist! Total ' + a | |
| 57 | b = stop - start | |
| 58 | print 'Hash Calculation Took ' + str(b) + 's' | |
| 59 | tmp = True | |
| 60 | while tmp: | |
| 61 | try: | |
| 62 | resp = urllib2.urlopen('http://65.26.252.225/quest/dia/krist/index.php?submitblock&address=' + id + '&nonce=' + str(nonce))
| |
| 63 | tmp = True | |
| 64 | except: | |
| 65 | tmp = False | |
| 66 | ||
| 67 | nonce = 0 | |
| 68 | score = 0 | |
| 69 | last = 0 | |
| 70 | thash = 0 | |
| 71 | target = 0 | |
| 72 | break |