Merge branch 'master' into optional_donation
authorForrest Voight <forrest.voight@gmail.com>
Thu, 24 Nov 2011 17:59:46 +0000 (12:59 -0500)
committerForrest Voight <forrest.voight@gmail.com>
Thu, 24 Nov 2011 17:59:46 +0000 (12:59 -0500)
Conflicts:
p2pool/data.py
p2pool/main.py

1  2 
p2pool/bitcoin/data.py
p2pool/data.py
p2pool/main.py
p2pool/p2p.py

Simple merge
diff --cc p2pool/data.py
@@@ -749,10 -558,10 +749,10 @@@ class BitcoinMainnet(networks.BitcoinMa
      NAME = 'bitcoin'
      P2P_PORT = 9333
      MAX_TARGET = 2**256//2**32 - 1
 -    PERSIST = True
 +    PERSIST = False
      WORKER_PORT = 9332
  
- class BitcoinTestnet(bitcoin_data.Testnet):
+ class BitcoinTestnet(networks.BitcoinTestnet):
      SHARE_PERIOD = 1 # seconds
      CHAIN_LENGTH = 24*60*60//5 # shares
      TARGET_LOOKBEHIND = 200 # shares
diff --cc p2pool/main.py
@@@ -495,23 -475,20 +495,23 @@@ def main(args)
              try:
                  # match up with transactions
                  header = bitcoin.getwork.decode_data(data)
 -                transactions = merkle_root_to_transactions.get(header['merkle_root'], None)
 -                if transactions is None:
 +                xxx = merkle_root_to_transactions.get(header['merkle_root'], None)
 +                if xxx is None:
                      print '''Couldn't link returned work's merkle root with its transactions - should only happen if you recently restarted p2pool'''
                      return False
 -                block = dict(header=header, txs=transactions)
 -                hash_ = bitcoin.data.block_header_type.hash256(block['header'])
 +                is_new, share_info, transactions = xxx
 +                new_share_info = share_info
 +                
 +                hash_ = bitcoin.data.block_header_type.hash256(header)
 +                
-                 pow = bitcoin.data.block_header_type.scrypt(header) if getattr(args.net, 'BITCOIN_POW_SCRYPT', False) else hash_
+                 pow_hash = args.net.BITCOIN_POW_FUNC(block['header'])
                  
-                 if pow <= header['target'] or p2pool_init.DEBUG:
 -                if pow_hash <= block['header']['target'] or p2pool_init.DEBUG:
++                if pow_hash <= header['target'] or p2pool_init.DEBUG:
                      if factory.conn.value is not None:
 -                        factory.conn.value.send_block(block=block)
 +                        factory.conn.value.send_block(block=dict(header=header, txs=transactions))
                      else:
                          print 'No bitcoind connection! Erp!'
-                     if pow <= header['target']:
 -                    if pow_hash <= block['header']['target']:
++                    if pow_hash <= header['target']:
                          print
                          print 'GOT BLOCK! Passing to bitcoind! bitcoin: %x' % (hash_,)
                          print
                      except:
                          log.err(None, 'Error while processing merged mining POW:')
                  
 -                target = p2pool.coinbase_type.unpack(transactions[0]['tx_ins'][0]['script'])['share_data']['target']
 +                target = new_share_info['target']
-                 if pow > target:
-                     print 'Worker submitted share with hash > target:\nhash  : %x\ntarget: %x' % (pow, target)
+                 if pow_hash > target:
+                     print 'Worker submitted share with hash > target:\nhash  : %x\ntarget: %x' % (pow_hash, target)
                      return False
 -                share = p2pool.Share.from_block(block, args.net)
 +                if is_new:
 +                    share = p2pool.NewShare(args.net, header, new_share_info, other_txs=transactions[1:])
 +                else:
 +                    share = p2pool.Share(args.net, header, share_info, other_txs=transactions[1:])
                  my_shares.add(share.hash)
                  if share.previous_hash != current_work.value['best_share_hash']:
                      doa_shares.add(share.hash)
diff --cc p2pool/p2p.py
Simple merge