mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-05 05:15:12 +00:00
Merge pull request #4371 from haarts/remove-explicit-protocol-mentions
Remove explicit protocol mentions
This commit is contained in:
commit
d538106caf
3 changed files with 10 additions and 17 deletions
|
@ -647,8 +647,7 @@ class Commands:
|
||||||
util.print_error('Got Response for %s' % address)
|
util.print_error('Got Response for %s' % address)
|
||||||
except BaseException as e:
|
except BaseException as e:
|
||||||
util.print_error(str(e))
|
util.print_error(str(e))
|
||||||
h = self.network.addr_to_scripthash(address)
|
self.network.subscribe_to_addresses([addr], callback)
|
||||||
self.network.send([('blockchain.scripthash.subscribe', [h])], callback)
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@command('wn')
|
@command('wn')
|
||||||
|
|
|
@ -625,13 +625,7 @@ class Network(util.DaemonThread):
|
||||||
# Response is now in canonical form
|
# Response is now in canonical form
|
||||||
self.process_response(interface, response, callbacks)
|
self.process_response(interface, response, callbacks)
|
||||||
|
|
||||||
def addr_to_scripthash(self, addr):
|
def map_scripthash_to_address(self, callback):
|
||||||
h = bitcoin.address_to_scripthash(addr)
|
|
||||||
if h not in self.h2addr:
|
|
||||||
self.h2addr[h] = addr
|
|
||||||
return h
|
|
||||||
|
|
||||||
def overload_cb(self, callback):
|
|
||||||
def cb2(x):
|
def cb2(x):
|
||||||
x2 = x.copy()
|
x2 = x.copy()
|
||||||
p = x2.pop('params')
|
p = x2.pop('params')
|
||||||
|
@ -641,13 +635,15 @@ class Network(util.DaemonThread):
|
||||||
return cb2
|
return cb2
|
||||||
|
|
||||||
def subscribe_to_addresses(self, addresses, callback):
|
def subscribe_to_addresses(self, addresses, callback):
|
||||||
hashes = [self.addr_to_scripthash(addr) for addr in addresses]
|
hash2address = {bitcoin.address_to_scripthash(address): address for address in addresses}
|
||||||
msgs = [('blockchain.scripthash.subscribe', [x]) for x in hashes]
|
self.h2addr.update(hash2address)
|
||||||
self.send(msgs, self.overload_cb(callback))
|
msgs = [('blockchain.scripthash.subscribe', [x]) for x in hash2address.keys()]
|
||||||
|
self.send(msgs, self.map_scripthash_to_address(callback))
|
||||||
|
|
||||||
def request_address_history(self, address, callback):
|
def request_address_history(self, address, callback):
|
||||||
h = self.addr_to_scripthash(address)
|
h = bitcoin.address_to_scripthash(address)
|
||||||
self.send([('blockchain.scripthash.get_history', [h])], self.overload_cb(callback))
|
self.h2addr.update({h: address})
|
||||||
|
self.send([('blockchain.scripthash.get_history', [h])], self.map_scripthash_to_address(callback))
|
||||||
|
|
||||||
def send(self, messages, callback):
|
def send(self, messages, callback):
|
||||||
'''Messages is a list of (method, params) tuples'''
|
'''Messages is a list of (method, params) tuples'''
|
||||||
|
|
|
@ -84,9 +84,7 @@ class WsClientThread(util.DaemonThread):
|
||||||
l = self.subscriptions.get(addr, [])
|
l = self.subscriptions.get(addr, [])
|
||||||
l.append((ws, amount))
|
l.append((ws, amount))
|
||||||
self.subscriptions[addr] = l
|
self.subscriptions[addr] = l
|
||||||
h = self.network.addr_to_scripthash(addr)
|
self.network.subscribe_to_addresses([addr], self.response_queue.put)
|
||||||
self.network.send([('blockchain.scripthash.subscribe', [h])], self.response_queue.put)
|
|
||||||
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
threading.Thread(target=self.reading_thread).start()
|
threading.Thread(target=self.reading_thread).start()
|
||||||
|
|
Loading…
Add table
Reference in a new issue