work
authorforrest <forrest@470744a7-cac9-478e-843e-5ec1b25c69e8>
Wed, 15 Jun 2011 22:37:35 +0000 (22:37 +0000)
committerforrest <forrest@470744a7-cac9-478e-843e-5ec1b25c69e8>
Wed, 15 Jun 2011 22:37:35 +0000 (22:37 +0000)
git-svn-id: svn://forre.st/p2pool@1311 470744a7-cac9-478e-843e-5ec1b25c69e8

main.py
p2p.py

diff --git a/main.py b/main.py
index 1c534d7..ad65431 100644 (file)
--- a/main.py
+++ b/main.py
@@ -238,10 +238,8 @@ def main(args):
                 raise ValueError('unknown result from chain.accept - %r' % (res,))
             
             w = dict(current_work.value)
-            w['highest_p2pool_share'] = w['current_chain'].get_highest_share()
+            w['highest_p2pool_share2'] = w['current_chain'].get_highest_share2()
             current_work.set(w)
-            
-            return bitcoin_p2p.block_hash(block['header']) <= net.TARGET_MULTIPLIER*conv.bits_to_target(block['header']['bits'])
         
         @defer.inlineCallbacks
         def getBlocksCallback2(chain_id_data, highest, contact):
@@ -341,13 +339,15 @@ def main(args):
                 return False
             share = p2pool.Share(header=header, txns=transactions)
             try:
-                return p2pCallback(share)
+                p2pCallback(share)
             except:
                 print
                 print 'Error processing data received from worker:'
                 traceback.print_exc()
                 print
                 return False
+            else:
+                return True
         
         reactor.listenTCP(args.worker_port, server.Site(worker_interface.WorkerInterface(current_work, compute, got_response)))
         
diff --git a/p2p.py b/p2p.py
index c0ecd4c..602bb5b 100644 (file)
--- a/p2p.py
+++ b/p2p.py
@@ -218,7 +218,7 @@ class Protocol(bitcoin_p2p.BaseProtocol):
     def handle_share0s(self, chains):
         for chain in chains:
             for hash_ in chain['hashes']:
-                self.node.handle_share_hash((chain['chain_id']['previous_p2pool_block'], chain['chain_id']['bits']), hash_)
+                self.node.handle_share_hash(p2pool.chain_id_type.pack(chain['chain_id']), hash_)
     def handle_share1s(self, share1s):
         for share1 in share1s:
             hash_ = bitcoin_p2p.block_hash(share1['header'])
@@ -432,6 +432,10 @@ class Node(object):
             self.addr_store[host, port] = services, old_first_seen, max(old_last_seen, timestamp)
         else:
             self.addr_store[host, port] = services, timestamp, timestamp
+    
+    
+    def handle_share_hash(self, chain_id_data, hash):
+        print (chain_id_data, hash)
 
 if __name__ == '__main__':
     p = random.randrange(2**15, 2**16)