Browse Source

remove height parameter from blockchain.transaction.get

seed_v14
ThomasV 7 years ago
parent
commit
f1666f208b
  1. 23
      lib/synchronizer.py

23
lib/synchronizer.py

@ -51,7 +51,7 @@ class Synchronizer(ThreadJob):
self.network = network
self.new_addresses = set()
# Entries are (tx_hash, tx_height) tuples
self.requested_tx = set()
self.requested_tx = {}
self.requested_histories = {}
self.requested_addrs = set()
self.lock = Lock()
@ -135,7 +135,7 @@ class Synchronizer(ThreadJob):
params, result = self.parse_response(response)
if not params:
return
tx_hash, tx_height = params
tx_hash = params[0]
#assert tx_hash == hash_encode(Hash(bytes.fromhex(result)))
tx = Transaction(result)
try:
@ -143,8 +143,8 @@ class Synchronizer(ThreadJob):
except Exception:
self.print_msg("cannot deserialize transaction, skipping", tx_hash)
return
tx_height = self.requested_tx.pop(tx_hash)
self.wallet.receive_tx_callback(tx_hash, tx, tx_height)
self.requested_tx.remove((tx_hash, tx_height))
self.print_error("received tx %s height: %d bytes: %d" %
(tx_hash, tx_height, len(tx.raw)))
# callbacks
@ -155,15 +155,16 @@ class Synchronizer(ThreadJob):
def request_missing_txs(self, hist):
# "hist" is a list of [tx_hash, tx_height] lists
missing = set()
requests = []
for tx_hash, tx_height in hist:
if self.wallet.transactions.get(tx_hash) is None:
missing.add((tx_hash, tx_height))
missing -= self.requested_tx
if missing:
requests = [('blockchain.transaction.get', tx) for tx in missing]
self.network.send(requests, self.tx_response)
self.requested_tx |= missing
if tx_hash in self.requested_tx:
continue
if tx_hash in self.wallet.transactions:
continue
requests.append(('blockchain.transaction.get', [tx_hash]))
self.requested_tx[tx_hash] = tx_height
self.network.send(requests, self.tx_response)
def initialize(self):
'''Check the initial state of the wallet. Subscribe to all its

Loading…
Cancel
Save