Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import hashlib
- import urllib2
- import math
- import time
- import timeit
- import sys
- for arg in sys.argv:
- id = arg
- #print("Mining for " + id)
- print("Mining for " + id)
- nonce = 0
- score = 400000000001L
- last = 0
- total = 0
- def recall():
- global last
- global target
- tmp = True
- while tmp:
- try:
- resp = urllib2.urlopen('http://65.26.252.225/quest/dia/krist/index.php?getwork')
- target = int(resp.read())
- resp.close()
- resp = urllib2.urlopen('http://65.26.252.225/quest/dia/krist/index.php?lastblock')
- last = resp.read()
- resp.close()
- tmp = False
- except:
- tmp = True
- while True:
- start = timeit.default_timer()
- while True:
- if math.floor(nonce / 250) * 250 == 0:
- recall()
- nonce = nonce + 540
- m = hashlib.sha256()
- sto = str(nonce)
- slast = str(last)
- thash = id + slast + sto
- m.update(thash)
- toutput = m.hexdigest()
- score = toutput[:12]
- score = int(score, 16)
- if score < target:
- break
- stop = timeit.default_timer()
- total += 50
- resp = urllib2.urlopen('http://65.26.252.225/quest/dia/krist/index.php?getbalance=' + id)
- a = resp.read()
- resp.close()
- print 'BLOCK! +50 Krist! Total ' + a
- b = stop - start
- print 'Hash Calculation Took ' + str(b) + 's'
- tmp = True
- while tmp:
- try:
- resp = urllib2.urlopen('http://65.26.252.225/quest/dia/krist/index.php?submitblock&address=' + id + '&nonce=' + str(nonce))
- tmp = True
- except:
- tmp = False
- nonce = 0
- score = 0
- last = 0
- thash = 0
- target = 0
- break
Add Comment
Please, Sign In to add comment