CONF_FILE_FUNC=lambda: os.path.join(os.path.join(os.environ['APPDATA'], 'Bitcoin') if platform.system() == 'Windows' else os.path.expanduser('~/Library/Application Support/Bitcoin/') if platform.system() == 'Darwin' else os.path.expanduser('~/.bitcoin'), 'bitcoin.conf'),
BLOCK_EXPLORER_URL_PREFIX='http://blockexplorer.com/block/',
ADDRESS_EXPLORER_URL_PREFIX='http://blockexplorer.com/address/',
- SANE_MAX_TARGET=2**256//2**32 - 1,
+ SANE_TARGET_RANGE=(2**256//2**32 - 1, 2**256//2**32 - 1),
),
bitcoin_testnet=math.Object(
P2P_PREFIX='fabfb5da'.decode('hex'),
CONF_FILE_FUNC=lambda: os.path.join(os.path.join(os.environ['APPDATA'], 'Bitcoin') if platform.system() == 'Windows' else os.path.expanduser('~/Library/Application Support/Bitcoin/') if platform.system() == 'Darwin' else os.path.expanduser('~/.bitcoin'), 'bitcoin.conf'),
BLOCK_EXPLORER_URL_PREFIX='http://blockexplorer.com/testnet/block/',
ADDRESS_EXPLORER_URL_PREFIX='http://blockexplorer.com/testnet/address/',
- SANE_MAX_TARGET=2**256//2**32 - 1,
+ SANE_TARGET_RANGE=(2**256//2**32 - 1, 2**256//2**32 - 1),
),
namecoin=math.Object(
CONF_FILE_FUNC=lambda: os.path.join(os.path.join(os.environ['APPDATA'], 'Namecoin') if platform.system() == 'Windows' else os.path.expanduser('~/Library/Application Support/Namecoin/') if platform.system() == 'Darwin' else os.path.expanduser('~/.namecoin'), 'bitcoin.conf'),
BLOCK_EXPLORER_URL_PREFIX='http://explorer.dot-bit.org/b/',
ADDRESS_EXPLORER_URL_PREFIX='http://explorer.dot-bit.org/a/',
- SANE_MAX_TARGET=2**256//2**32 - 1,
+ SANE_TARGET_RANGE=(2**256//2**32 - 1, 2**256//2**32 - 1),
),
namecoin_testnet=math.Object(
P2P_PREFIX='fabfb5fe'.decode('hex'),
CONF_FILE_FUNC=lambda: os.path.join(os.path.join(os.environ['APPDATA'], 'Namecoin') if platform.system() == 'Windows' else os.path.expanduser('~/Library/Application Support/Namecoin/') if platform.system() == 'Darwin' else os.path.expanduser('~/.namecoin'), 'bitcoin.conf'),
BLOCK_EXPLORER_URL_PREFIX='http://testnet.explorer.dot-bit.org/b/',
ADDRESS_EXPLORER_URL_PREFIX='http://testnet.explorer.dot-bit.org/a/',
- SANE_MAX_TARGET=2**256//2**32 - 1,
+ SANE_TARGET_RANGE=(2**256//2**32 - 1, 2**256//2**32 - 1),
),
litecoin=math.Object(
CONF_FILE_FUNC=lambda: os.path.join(os.path.join(os.environ['APPDATA'], 'Litecoin') if platform.system() == 'Windows' else os.path.expanduser('~/Library/Application Support/Litecoin/') if platform.system() == 'Darwin' else os.path.expanduser('~/.litecoin'), 'litecoin.conf'),
BLOCK_EXPLORER_URL_PREFIX='http://abe.liteco.in/block/',
ADDRESS_EXPLORER_URL_PREFIX='http://abe.liteco.in/address/',
- SANE_MAX_TARGET=2**256//1000 - 1,
+ SANE_TARGET_RANGE=(2**256//1000000000 - 1, 2**256//1000 - 1),
),
litecoin_testnet=math.Object(
P2P_PREFIX='fcc1b7dc'.decode('hex'),
CONF_FILE_FUNC=lambda: os.path.join(os.path.join(os.environ['APPDATA'], 'Litecoin') if platform.system() == 'Windows' else os.path.expanduser('~/Library/Application Support/Litecoin/') if platform.system() == 'Darwin' else os.path.expanduser('~/.litecoin'), 'litecoin.conf'),
BLOCK_EXPLORER_URL_PREFIX='http://nonexistent-litecoin-testnet-explorer/block/',
ADDRESS_EXPLORER_URL_PREFIX='http://nonexistent-litecoin-testnet-explorer/address/',
- SANE_MAX_TARGET=2**256//1000 - 1,
+ SANE_TARGET_RANGE=(2**256//1000000000 - 1, 2**256//1000 - 1),
),
)
for net_name, net in nets.iteritems():
if len(self.recent_shares_ts_work) == 50:
hash_rate = sum(work for ts, work in self.recent_shares_ts_work[1:])//(self.recent_shares_ts_work[-1][0] - self.recent_shares_ts_work[0][0])
if hash_rate:
- target = min(target, int(4*2**256/hash_rate))
+ target = min(target, int(2**256/hash_rate))
else:
target = desired_pseudoshare_target
target = max(target, share_info['bits'].target)
for aux_work in current_work.value['mm_chains'].itervalues():
target = max(target, aux_work['target'])
- target = min(target, net.PARENT.SANE_MAX_TARGET)
+ target = math.clip(target, net.PARENT.SANE_TARGET_RANGE)
transactions = [generate_tx] + list(current_work2.value['transactions'])
packed_generate_tx = bitcoin_data.tx_type.pack(generate_tx)