Skip to content

Commit

Permalink
changed version check to >=0.7 or /P2SH/ in coinbaseflags/aux
Browse files Browse the repository at this point in the history
  • Loading branch information
forrestv committed Mar 20, 2012
1 parent 6f7ce7e commit 28c928e
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions p2pool/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@
from . import p2p, networks, web
import p2pool, p2pool.data as p2pool_data

def bitcoin_version_good(v):
major, minor, patch = v//10000, v//100%100, v%100
return (major >= 6) or (major == 5 and minor == 0 and patch >= 6) or (major == 5 and minor >= 4)

@deferral.retry('Error getting work from bitcoind:', 3)
@defer.inlineCallbacks
def getwork(bitcoind):
Expand Down Expand Up @@ -59,16 +55,20 @@ def main(args, net, datadir_path, merged_urls, worker_endpoint):
url = 'http://%s:%i/' % (args.bitcoind_address, args.bitcoind_rpc_port)
print '''Testing bitcoind RPC connection to '%s' with username '%s'...''' % (url, args.bitcoind_rpc_username)
bitcoind = jsonrpc.Proxy(url, dict(Authorization='Basic ' + base64.b64encode(args.bitcoind_rpc_username + ':' + args.bitcoind_rpc_password)), timeout=30)
@deferral.retry('Error while checking Bitcoin connection:', 1)
@defer.inlineCallbacks
def check():
if not (yield net.PARENT.RPC_CHECK)(bitcoind):
print >>sys.stderr, " Check failed! Make sure that you're connected to the right bitcoind with --bitcoind-rpc-port!"
raise deferral.RetrySilentlyException()
if not bitcoin_version_good((yield bitcoind.rpc_getinfo())['version']):
v = (yield bitcoind.rpc_getinfo())['version']
temp_work = yield getwork(bitcoind)
major, minor, patch = v//10000, v//100%100, v%100
if not ((major >= 7) or '/P2SH/' in temp_work['coinbaseflags']):
print >>sys.stderr, ' Bitcoin version too old! BIP16 support required! Upgrade to 0.6.0rc4 or greater!'
raise deferral.RetrySilentlyException()
yield deferral.retry('Error while checking Bitcoin connection:', 1)(check)()
temp_work = yield getwork(bitcoind)
defer.returnValue(temp_work)
temp_work = yield check()
print ' ...success!'
print ' Current block hash: %x' % (temp_work['previous_block_hash'],)
print
Expand Down

0 comments on commit 28c928e

Please sign in to comment.