commit 936db23d3c7178fb550947bce727638932aa26b1
parent 8fabc5bb2df92b4fac107143ed6464c454355ca3
Author: ThomasV <thomasv@gitorious>
Date: Thu, 12 Jan 2012 15:35:02 +0300
standardize send_tx and new_session parameters
Diffstat:
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/server/server.py b/server/server.py
@@ -324,7 +324,11 @@ def send_tx(tx):
postdata = dumps({"method": 'importtransaction', 'params': [tx], 'id':'jsonrpc'})
respdata = urllib.urlopen(bitcoind_url, postdata).read()
r = loads(respdata)
- return r
+ if r['error'] != None:
+ out = "error: transaction rejected by memorypool"
+ else:
+ out = r['result']
+ return out
@@ -402,7 +406,7 @@ def poll_session(session_id):
return out
-def new_session(addresses, version):
+def new_session(version, addresses):
session_id = random_string(10)
sessions[session_id] = { 'addresses':{}, 'version':version }
for a in addresses:
@@ -478,7 +482,7 @@ def do_command(cmd, data, ipaddr):
print "error", data
return None
print time.strftime("[%d/%m/%Y-%H:%M:%S]"), "new session", ipaddr, addresses[0] if addresses else addresses, len(addresses), version
- out = new_session(addresses, version)
+ out = new_session(version, addresses)
elif cmd=='update_session':
try:
@@ -549,10 +553,6 @@ def do_command(cmd, data, ipaddr):
elif cmd =='tx':
r = send_tx(data)
- if r['error'] != None:
- out = "error: transaction rejected by memorypool"
- else:
- out = r['result']
print "sent tx:", out
elif cmd == 'stop':