callbacks

This commit is contained in:
ThomasV 2012-03-16 22:18:58 +01:00
parent bb82fc03d3
commit 31a1addce5
2 changed files with 17 additions and 9 deletions

View File

@ -270,19 +270,13 @@ class TCPInterface(Interface):
status = c.get('status')
if addr in self.addresses_waiting_for_status:
self.addresses_waiting_for_status.remove(addr)
if wallet.status.get(addr) != status:
wallet.status[addr] = status
self.send('address.get_history', addr)
self.addresses_waiting_for_history.append(addr)
wallet.get_status_callback(addr, status)
elif cmd == 'address.get_history':
addr = c.get('address')
if addr in self.addresses_waiting_for_history:
self.addresses_waiting_for_history.remove(addr)
wallet.history[addr] = data
wallet.synchronize()
wallet.update_tx_history()
wallet.save()
wallet.get_history_callback(addr, data)
self.was_updated = True
else:
print "received message:", c
@ -308,6 +302,10 @@ class TCPInterface(Interface):
def get_servers(self):
self.send('server.peers')
def get_history(self,addr):
self.send('address.get_history', addr)
self.addresses_waiting_for_history.append(addr)
def start_session(self, wallet):
self.s = socket.socket( socket.AF_INET, socket.SOCK_STREAM )
self.s.settimeout(1)

View File

@ -703,6 +703,17 @@ class Wallet:
else:
return s
def get_status_callback(self, addr, status):
if self.status.get(addr) != status:
self.status[addr] = status
self.interface.get_history(addr)
def get_history_callback(self, addr, data):
self.history[addr] = data
self.synchronize()
self.update_tx_history()
self.save()
def get_tx_history(self):
lines = self.tx_history.values()
lines = sorted(lines, key=operator.itemgetter("nTime"))
@ -828,7 +839,6 @@ class Wallet:
self.imported_keys[k] = c
self.save()
def get_alias(self, alias, interactive = False, show_message=None, question = None):
try:
target, signing_address, auth_name = self.read_alias(alias)