made share hash cover entire share rather than just the block header
authorForrest Voight <forrest@forre.st>
Mon, 18 Jul 2011 19:11:19 +0000 (15:11 -0400)
committerForrest Voight <forrest@forre.st>
Mon, 18 Jul 2011 19:11:19 +0000 (15:11 -0400)
p2pool/data.py
p2pool/main.py
p2pool/p2p.py

index 7a9007c..6a14224 100644 (file)
@@ -163,10 +163,11 @@ class Share(object):
         if len(self.nonce) > 20:
             raise ValueError('nonce too long!')
         
-        self.hash = bitcoin_data.block_header_type.hash256(header)
+        self.bitcoin_hash = bitcoin_data.block_header_type.hash256(header)
+        self.hash = share1a_type.hash256(self.as_share1a())
         
-        if self.hash > self.target2:
-            print 'hash', hex(self.hash)
+        if self.bitcoin_hash > self.target2:
+            print 'hash', hex(self.bitcoin_hash)
             print 'targ', hex(self.target2)
             raise ValueError('not enough work!')
         
index 0fac852..cdc6d22 100644 (file)
@@ -161,9 +161,9 @@ def main(args):
             #    peer2.send_getshares(hashes=[share_hash], parents=2000)
             
             if share.gentx is not None:
-                if share.hash <= share.header['target']:
+                if share.bitcoin_hash <= share.header['target']:
                     print
-                    print 'GOT BLOCK! Passing to bitcoind! %x' % (share.hash,)
+                    print 'GOT BLOCK! Passing to bitcoind! %x bitcoin: %x' % (share.hash, share.bitcoin_hash,)
                     print
                     if factory.conn.value is not None:
                         factory.conn.value.send_block(block=share.as_block())
index 6cb513c..8d0a8b0 100644 (file)
@@ -227,7 +227,7 @@ class Protocol(bitcoin_p2p.BaseProtocol):
         # XXX doesn't need to send full block when it's not urgent
         # eg. when getting history
         for share in shares:
-            if share.hash <= share.header['target']:
+            if share.bitcoin_hash <= share.header['target']:
                 share1bs.append(share.as_share1b())
             else:
                 if self.mode == 0 and not full: