Browse Source

more fixes for the 0.6 servers

283
thomasv 13 years ago
parent
commit
8fc042ee22
  1. 4
      lib/verifier.py
  2. 29
      lib/wallet.py

4
lib/verifier.py

@ -32,7 +32,7 @@ class WalletVerifier(threading.Thread):
self.daemon = True self.daemon = True
self.config = config self.config = config
self.interface = interface self.interface = interface
self.transactions = {} # monitored transactions self.transactions = {} # requested verifications (with height sent by the requestor)
self.interface.register_channel('verifier') self.interface.register_channel('verifier')
self.verified_tx = config.get('verified_tx',{}) # height of verified tx self.verified_tx = config.get('verified_tx',{}) # height of verified tx
@ -52,10 +52,12 @@ class WalletVerifier(threading.Thread):
if tx in self.transactions.keys(): if tx in self.transactions.keys():
return (self.local_height - self.verified_tx[tx] + 1) if tx in self.verified_tx else -1 return (self.local_height - self.verified_tx[tx] + 1) if tx in self.verified_tx else -1
else: else:
#print "verifier: tx not in list", tx
return 0 return 0
def add(self, tx_hash, tx_height): def add(self, tx_hash, tx_height):
""" add a transaction to the list of monitored transactions. """ """ add a transaction to the list of monitored transactions. """
assert tx_height > 0
with self.lock: with self.lock:
if tx_hash not in self.transactions.keys(): if tx_hash not in self.transactions.keys():
self.transactions[tx_hash] = tx_height self.transactions[tx_hash] = tx_height

29
lib/wallet.py

@ -550,6 +550,9 @@ class Wallet:
with self.lock: with self.lock:
self.transactions[tx_hash] = tx self.transactions[tx_hash] = tx
tx_height = tx.get('height')
if tx_height>0: self.verifier.add(tx_hash, tx_height)
self.update_tx_outputs(tx_hash) self.update_tx_outputs(tx_hash)
self.save() self.save()
@ -890,18 +893,21 @@ class Wallet:
def set_verifier(self, verifier): def set_verifier(self, verifier):
self.verifier = verifier self.verifier = verifier
# set the timestamp for transactions that need it for tx_hash, tx in self.transactions.items():
for hist in self.history.values(): tx_height = tx.get('height')
if hist == ['*']: continue if tx_height <1:
for tx_hash, tx_height in hist: print_error( "skipping", tx_hash, tx_height )
tx = self.transactions.get(tx_hash) continue
if tx and not tx.get('timestamp'):
timestamp = self.verifier.get_timestamp(tx_height) if tx_height>0:
if timestamp: self.verifier.add(tx_hash, tx_height)
self.set_tx_timestamp(tx_hash, timestamp)
# set the timestamp for transactions that need it
if tx and not tx.get('timestamp'):
timestamp = self.verifier.get_timestamp(tx_height)
if timestamp:
self.set_tx_timestamp(tx_hash, timestamp)
if tx_height>0:
self.verifier.add(tx_hash, tx_height)
@ -1123,6 +1129,7 @@ class WalletSynchronizer(threading.Thread):
vds = deserialize.BCDataStream() vds = deserialize.BCDataStream()
vds.write(raw_tx.decode('hex')) vds.write(raw_tx.decode('hex'))
d = deserialize.parse_Transaction(vds) d = deserialize.parse_Transaction(vds)
d['height'] = tx_height
d['tx_hash'] = tx_hash d['tx_hash'] = tx_hash
d['timestamp'] = self.wallet.verifier.get_timestamp(tx_height) d['timestamp'] = self.wallet.verifier.get_timestamp(tx_height)
return d return d

Loading…
Cancel
Save