electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit dd849964d1c3aebebd52d28221ec24c25839f6d5
parent 9af2c207066666e4401b73323f33313488e115dd
Author: ThomasV <thomasv@gitorious>
Date:   Fri,  5 Sep 2014 14:51:37 +0200

interface: forward errors

Diffstat:
Mlib/interface.py | 9++++-----
Mlib/network_proxy.py | 13+++++++------
2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/lib/interface.py b/lib/interface.py @@ -82,10 +82,6 @@ class TcpInterface(threading.Thread): error = response.get('error') result = response.get('result') - if error: - print_error("received error:", response) - return - if msg_id is not None: with self.lock: method, params, _id, queue = self.unanswered_requests.pop(msg_id) @@ -114,7 +110,10 @@ class TcpInterface(threading.Thread): self.is_ping = False return - queue.put((self, {'method':method, 'params':params, 'result':result, 'id':_id})) + if error: + queue.put((self, {'method':method, 'params':params, 'error':error, 'id':_id})) + else: + queue.put((self, {'method':method, 'params':params, 'result':result, 'id':_id})) def get_socket(self): diff --git a/lib/network_proxy.py b/lib/network_proxy.py @@ -109,6 +109,7 @@ class NetworkProxy(threading.Thread): msg_id = response.get('id') result = response.get('result') + error = response.get('error') if msg_id is not None: with self.lock: method, params, callback = self.unanswered_requests.pop(msg_id) @@ -125,7 +126,7 @@ class NetworkProxy(threading.Thread): return - r = {'method':method, 'params':params, 'result':result, 'id':msg_id} + r = {'method':method, 'params':params, 'result':result, 'id':msg_id, 'error':error} callback(r) @@ -171,11 +172,11 @@ class NetworkProxy(threading.Thread): while ids: r = queue.get(True, timeout) _id = r.get('id') - if _id in ids: - ids.remove(_id) - res[_id] = r.get('result') - else: - raise + ids.remove(_id) + if r.get('error'): + return BaseException(r.get('error')) + result = r.get('result') + res[_id] = r.get('result') out = [] for _id in id2: out.append(res[_id])