electrum

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

commit a0a67221bb4c3e072b410d63d8a2ea28bff75942
parent d6d9b5f1d1b51cd2beae0cef2fc381a0ef22f2fd
Author: ThomasV <thomasv@gitorious>
Date:   Fri, 23 Mar 2012 17:46:48 +0100

fix status bar display

Diffstat:
Mclient/interface.py | 31+++++++++++++++----------------
Mclient/wallet.py | 13++++++++-----
2 files changed, 23 insertions(+), 21 deletions(-)

diff --git a/client/interface.py b/client/interface.py @@ -25,18 +25,14 @@ DEFAULT_SERVERS = ['electrum.bitcoins.sk','ecdsa.org','electrum.novit.ro'] # li class Interface: - def __init__(self, host, port, address_callback=None, history_callback=None, newblock_callback=None, sync_cb=None): + def __init__(self, host, port): self.host = host self.port = port - self.sync_callback = sync_cb - self.address_callback = address_callback - self.history_callback = history_callback - self.newblock_callback = newblock_callback self.servers = [] # actual list from IRC self.rtime = 0 - self.is_connected = False + self.is_connected = True #only asynchrnous self.addresses_waiting_for_status = [] @@ -50,7 +46,7 @@ class Interface: def is_up_to_date(self): - return not ( self.addresses_waiting_for_status or self.addresses_waiting_for_history ) + return self.responses.empty() and not ( self.addresses_waiting_for_status or self.addresses_waiting_for_history ) def send_tx(self, data): @@ -75,18 +71,20 @@ class Interface: if error: print "received error:", c, method, params else: - #self.handle_response(method, params, result) - if method == 'address.subscribe': - addr = params[-1] - if addr in self.addresses_waiting_for_status: - self.addresses_waiting_for_status.remove(addr) - elif method == 'address.get_history': - addr = params[0] - if addr in self.addresses_waiting_for_history: - self.addresses_waiting_for_history.remove(addr) + self.update_waiting_lists(method, params) self.responses.put({'method':method, 'params':params, 'result':result}) + def update_waiting_lists(self, method, params): + if method == 'address.subscribe': + addr = params[-1] + if addr in self.addresses_waiting_for_status: + self.addresses_waiting_for_status.remove(addr) + elif method == 'address.get_history': + addr = params[0] + if addr in self.addresses_waiting_for_history: + self.addresses_waiting_for_history.remove(addr) + def subscribe(self, addresses): messages = [] @@ -215,6 +213,7 @@ class NativeInterface(PollingInterface): if cmd == 'new_session': self.session_id, self.message = ast.literal_eval( out ) else: + self.update_waiting_lists(method, params) self.responses.put({'method':method, 'params':params, 'result':out}) diff --git a/client/wallet.py b/client/wallet.py @@ -950,12 +950,12 @@ class Wallet: if blocks == -1: raise BaseException("session not found") self.blocks = int(blocks) if changed_addresses: - self.is_up_to_date = False + #self.is_up_to_date = False self.was_updated = True for addr, status in changed_addresses.items(): self.receive_status_callback(addr, status) - else: - self.is_up_to_date = True + #else: + # self.is_up_to_date = True elif method == 'server.peers': #print "Received server list: ", result @@ -984,13 +984,16 @@ class Wallet: else: print "unknown message:", method, params, result + def update(self): self.up_to_date_event.wait() + def run(self): while self.interface.is_connected: - new = self.synchronize() - if self.interface.is_up_to_date() and not new: + # the interface should use an input queue for requests so that we don't care about synchronous + is_new = self.synchronize() # in synchronous mode, this puts new responses in the queue + if self.interface.is_up_to_date() and not is_new: self.up_to_date = True self.up_to_date_event.set() else: