Browse Source

remove height parameter from blockchain.transaction.get

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

Loading…
Cancel
Save