changed example code for bitcoin.p2p to work and do something more useful
authorForrest Voight <forrest@forre.st>
Tue, 13 Dec 2011 06:02:24 +0000 (01:02 -0500)
committerForrest Voight <forrest@forre.st>
Tue, 13 Dec 2011 06:02:24 +0000 (01:02 -0500)
p2pool/bitcoin/p2p.py

index 3b5bf1e..ea29b82 100644 (file)
@@ -385,16 +385,15 @@ class HeightTracker(object):
         self._think2_task.stop()
 
 if __name__ == '__main__':
-    factory = ClientFactory(bitcoin_data.BitcoinMainnet)
+    from . import networks
+    factory = ClientFactory(networks.BitcoinMainnet)
     reactor.connectTCP('127.0.0.1', 8333, factory)
-    h = HeightTracker(factory)
     
     @repr
     @apply
     @defer.inlineCallbacks
     def think():
-        while True:
-            yield deferral.sleep(1)
-            print h.get_min_height(0xa285c3cb2a90ac7194cca034512748289e2526d9d7ae6ee7523)
+        print (yield (yield factory.getProtocol()).get_block(0x000000000000003aaaf7638f9f9c0d0c60e8b0eb817dcdb55fd2b1964efc5175))
+        reactor.stop()
     
     reactor.run()