go back to 1 pseudoshare/second, but fix bitcoin pseudoshare target to H==0
authorForrest Voight <forrest@forre.st>
Thu, 17 May 2012 04:29:59 +0000 (00:29 -0400)
committerForrest Voight <forrest@forre.st>
Thu, 17 May 2012 04:38:25 +0000 (00:38 -0400)
p2pool/bitcoin/networks.py
p2pool/main.py

index aa86224..a0f9b53 100644 (file)
@@ -22,7 +22,7 @@ nets = dict(
         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'),
@@ -39,7 +39,7 @@ nets = dict(
         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(
@@ -57,7 +57,7 @@ nets = dict(
         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'),
@@ -74,7 +74,7 @@ nets = dict(
         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(
@@ -92,7 +92,7 @@ nets = dict(
         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'),
@@ -109,7 +109,7 @@ nets = dict(
         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():
index c8d6584..d2b83fe 100644 (file)
@@ -565,13 +565,13 @@ def main(args, net, datadir_path, merged_urls, worker_endpoint):
                     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)