dynamically create subclasses of jsonrpc.Error for individual error codes so they...
[p2pool.git] / p2pool / main.py
index c3cede8..d3425b6 100644 (file)
@@ -31,11 +31,9 @@ import p2pool, p2pool.data as p2pool_data
 def getwork(bitcoind):
     try:
         work = yield bitcoind.rpc_getmemorypool()
-    except jsonrpc.Error, e:
-        if e.code == -32601: # Method not found
-            print >>sys.stderr, 'Error: Bitcoin version too old! Upgrade to v0.5 or newer!'
-            raise deferral.RetrySilentlyException()
-        raise
+    except jsonrpc.Error_for_code(-32601): # Method not found
+        print >>sys.stderr, 'Error: Bitcoin version too old! Upgrade to v0.5 or newer!'
+        raise deferral.RetrySilentlyException()
     packed_transactions = [x.decode('hex') for x in work['transactions']]
     if 'height' not in work:
         work['height'] = (yield bitcoind.rpc_getblock(work['previousblockhash']))['height'] + 1