From a3b137ba2e3450736afcd580779f71654567f0df Mon Sep 17 00:00:00 2001 From: Forrest Voight Date: Sun, 12 Feb 2012 23:23:03 -0500 Subject: [PATCH] added SANE_MAX_TARGET attribute to currency net definitions for maximum pseudoshare target --- p2pool/bitcoin/networks.py | 6 ++++++ p2pool/main.py | 2 +- 2 files changed, 7 insertions(+), 1 deletions(-) diff --git a/p2pool/bitcoin/networks.py b/p2pool/bitcoin/networks.py index 97db568..432928e 100644 --- a/p2pool/bitcoin/networks.py +++ b/p2pool/bitcoin/networks.py @@ -21,6 +21,7 @@ nets = dict( SYMBOL='BTC', 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/', + SANE_MAX_TARGET=2**256//2**32 - 1, ), bitcoin_testnet=math.Object( P2P_PREFIX='fabfb5da'.decode('hex'), @@ -36,6 +37,7 @@ nets = dict( SYMBOL='tBTC', 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/', + SANE_MAX_TARGET=2**256//2**32 - 1, ), nameecoin=math.Object( @@ -52,6 +54,7 @@ nets = dict( SYMBOL='NMC', 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/', + SANE_MAX_TARGET=2**256//2**32 - 1, ), namecoin_testnet=math.Object( P2P_PREFIX='fabfb5fe'.decode('hex'), @@ -67,6 +70,7 @@ nets = dict( SYMBOL='tNMC', 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/', + SANE_MAX_TARGET=2**256//2**32 - 1, ), litecoin=math.Object( @@ -83,6 +87,7 @@ nets = dict( SYMBOL='LTC', 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/', + SANE_MAX_TARGET=2**256//1000 - 1, ), litecoin_testnet=math.Object( P2P_PREFIX='fcc1b7dc'.decode('hex'), @@ -98,6 +103,7 @@ nets = dict( SYMBOL='tLTC', 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/', + SANE_MAX_TARGET=2**256//1000 - 1, ), ) for net_name, net in nets.iteritems(): diff --git a/p2pool/main.py b/p2pool/main.py index f9f2fc4..d830986 100644 --- a/p2pool/main.py +++ b/p2pool/main.py @@ -517,7 +517,7 @@ def main(args, net, datadir_path, merged_urls, worker_endpoint): net=net, ) - target = 2**256//2**32 - 1 + target = net.PARENT.SANE_MAX_TARGET if len(self.recent_shares_ts_work) == 50: hash_rate = sum(work for ts, work in self.recent_shares_ts_work)//(self.recent_shares_ts_work[-1][0] - self.recent_shares_ts_work[0][0]) target = min(target, 2**256//(hash_rate * 5)) -- 1.7.1