X-Git-Url: https://git.novaco.in/?p=p2pool.git;a=blobdiff_plain;f=p2pool%2Fbitcoin%2Fnetworks.py;h=c604696989fff9c38729cc15902c9725536291a7;hp=7c60f80b465ef5b6b3f140f2799bad9fd7b7c678;hb=f727ee10bf40c7b050b6fcc54ac491a21199b6ec;hpb=d43be753b133c401cbc5a933229a42d2f1d76e54 diff --git a/p2pool/bitcoin/networks.py b/p2pool/bitcoin/networks.py index 7c60f80..c604696 100644 --- a/p2pool/bitcoin/networks.py +++ b/p2pool/bitcoin/networks.py @@ -4,7 +4,16 @@ import platform from twisted.internet import defer from . import data -from p2pool.util import math, pack +from p2pool.util import math, pack, jsonrpc + +@defer.inlineCallbacks +def check_genesis_block(bitcoind, genesis_block_hash): + try: + yield bitcoind.rpc_getblock(genesis_block_hash) + except jsonrpc.Error_for_code(-5): + defer.returnValue(False) + else: + defer.returnValue(True) nets = dict( bitcoin=math.Object( @@ -13,7 +22,7 @@ nets = dict( ADDRESS_VERSION=0, RPC_PORT=8332, RPC_CHECK=defer.inlineCallbacks(lambda bitcoind: defer.returnValue( - 0 == (yield bitcoind.rpc_getblock('000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f'))['height'] and + (yield check_genesis_block(bitcoind, '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f')) and not (yield bitcoind.rpc_getinfo())['testnet'] )), SUBSIDY_FUNC=lambda height: 50*100000000 >> (height + 1)//210000,