electrum

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

commit ed8f9666df292017be85b32794cb4e78e2bb0411
parent 087490a197004b4e5fd5ca823a628c18c15e44d6
Author: ThomasV <thomasv@gitorious>
Date:   Tue, 29 Jul 2014 00:15:21 +0200

remove interface.synchronous_get

Diffstat:
Mlib/blockchain.py | 29++++++-----------------------
Mlib/interface.py | 15---------------
Mlib/network.py | 5-----
3 files changed, 6 insertions(+), 43 deletions(-)

diff --git a/lib/blockchain.py b/lib/blockchain.py @@ -291,32 +291,16 @@ class Blockchain(threading.Thread): print_error("requesting header %d from %s"%(h, i.server)) i.send_request({'method':'blockchain.block.get_header', 'params':[h]}, queue) - def retrieve_header(self, i, queue): + def retrieve_request(self, queue): while True: try: ir = queue.get(timeout=1) except Queue.Empty: - print_error('retrieve_header: timeout', i.server) + print_error('blockchain: request timeout') continue - - if not ir: - continue - i, r = ir - - if r.get('error'): - print_error('Verifier received an error:', r) - continue - - # 3. handle response - method = r['method'] - params = r['params'] result = r['result'] - - if method == 'blockchain.block.get_header': - return result - - + return result def get_chain(self, interface, final_header): @@ -328,7 +312,7 @@ class Blockchain(threading.Thread): while self.is_running(): if requested_header: - header = self.retrieve_header(interface, queue) + header = self.retrieve_request(queue) if not header: return chain = [ header ] + chain requested_header = False @@ -361,9 +345,8 @@ class Blockchain(threading.Thread): n = min_index while n < max_index + 1: print_error( "Requesting chunk:", n ) - r = i.synchronous_get([ ('blockchain.block.get_chunk',[n])])[0] - if not r: - continue + i.send_request({'method':'blockchain.block.get_chunk', 'params':[n]}, queue) + r = self.retrieve_request(queue) try: self.verify_chunk(n, r) n = n + 1 diff --git a/lib/interface.py b/lib/interface.py @@ -341,21 +341,6 @@ class Interface(threading.Thread): # print_error( "change status", self.server, self.is_connected) self.response_queue.put((self, None)) - def synchronous_get(self, requests, timeout=100000000): - queue = Queue.Queue() - ids = self.send(requests, lambda i,r: queue.put(r)) - id2 = ids[:] - res = {} - while ids: - r = queue.get(True, timeout) - _id = r.get('id') - if _id in ids: - ids.remove(_id) - res[_id] = r.get('result') - out = [] - for _id in id2: - out.append(res[_id]) - return out class HTTP_Interface(Interface): diff --git a/lib/network.py b/lib/network.py @@ -447,11 +447,6 @@ class Network(threading.Thread): with self.lock: return self.running - - def synchronous_get(self, requests, timeout=100000000): - return self.interface.synchronous_get(requests) - - def get_header(self, tx_height): return self.blockchain.read_header(tx_height)