tremove height parameter from blockchain.transaction.get - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit f1666f208b2127539a3b3b87b94e42f27c42b819 DIR parent 84962ea6f1090a8310d99eb78fcb92b91ef7fa00 HTML Author: ThomasV <thomasv@electrum.org> Date: Wed, 6 Sep 2017 22:09:15 +0200 remove height parameter from blockchain.transaction.get Diffstat: M lib/synchronizer.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) --- DIR diff --git a/lib/synchronizer.py b/lib/synchronizer.py t@@ -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() t@@ -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: t@@ -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 t@@ -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