mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-03 02:35:20 +00:00
move get_status to synchronizer
This commit is contained in:
parent
6322714222
commit
076ecb2680
2 changed files with 11 additions and 10 deletions
|
@ -25,6 +25,7 @@
|
||||||
|
|
||||||
|
|
||||||
from threading import Lock
|
from threading import Lock
|
||||||
|
import hashlib
|
||||||
|
|
||||||
from bitcoin import Hash, hash_encode
|
from bitcoin import Hash, hash_encode
|
||||||
from transaction import Transaction
|
from transaction import Transaction
|
||||||
|
@ -78,13 +79,21 @@ class Synchronizer(ThreadJob):
|
||||||
addresses)
|
addresses)
|
||||||
self.network.send(msgs, self.addr_subscription_response)
|
self.network.send(msgs, self.addr_subscription_response)
|
||||||
|
|
||||||
|
def get_status(self, h):
|
||||||
|
if not h:
|
||||||
|
return None
|
||||||
|
status = ''
|
||||||
|
for tx_hash, height in h:
|
||||||
|
status += tx_hash + ':%d:' % height
|
||||||
|
return hashlib.sha256(status).digest().encode('hex')
|
||||||
|
|
||||||
def addr_subscription_response(self, response):
|
def addr_subscription_response(self, response):
|
||||||
params, result = self.parse_response(response)
|
params, result = self.parse_response(response)
|
||||||
if not params:
|
if not params:
|
||||||
return
|
return
|
||||||
addr = params[0]
|
addr = params[0]
|
||||||
history = self.wallet.get_address_history(addr)
|
history = self.wallet.get_address_history(addr)
|
||||||
if self.wallet.get_status(history) != result:
|
if self.get_status(history) != result:
|
||||||
if self.requested_histories.get(addr) is None:
|
if self.requested_histories.get(addr) is None:
|
||||||
self.requested_histories[addr] = result
|
self.requested_histories[addr] = result
|
||||||
self.network.send([('blockchain.address.get_history', [addr])],
|
self.network.send([('blockchain.address.get_history', [addr])],
|
||||||
|
@ -109,7 +118,7 @@ class Synchronizer(ThreadJob):
|
||||||
if len(hashes) != len(result):
|
if len(hashes) != len(result):
|
||||||
self.print_error("error: server history has non-unique txids: %s"% addr)
|
self.print_error("error: server history has non-unique txids: %s"% addr)
|
||||||
# Check that the status corresponds to what was announced
|
# Check that the status corresponds to what was announced
|
||||||
elif self.wallet.get_status(hist) != server_status:
|
elif self.get_status(hist) != server_status:
|
||||||
self.print_error("error: status mismatch: %s" % addr)
|
self.print_error("error: status mismatch: %s" % addr)
|
||||||
else:
|
else:
|
||||||
# Store received history
|
# Store received history
|
||||||
|
|
|
@ -713,14 +713,6 @@ class Abstract_Wallet(PrintError):
|
||||||
with self.lock:
|
with self.lock:
|
||||||
return self.history.get(address, [])
|
return self.history.get(address, [])
|
||||||
|
|
||||||
def get_status(self, h):
|
|
||||||
if not h:
|
|
||||||
return None
|
|
||||||
status = ''
|
|
||||||
for tx_hash, height in h:
|
|
||||||
status += tx_hash + ':%d:' % height
|
|
||||||
return hashlib.sha256( status ).digest().encode('hex')
|
|
||||||
|
|
||||||
def find_pay_to_pubkey_address(self, prevout_hash, prevout_n):
|
def find_pay_to_pubkey_address(self, prevout_hash, prevout_n):
|
||||||
dd = self.txo.get(prevout_hash, {})
|
dd = self.txo.get(prevout_hash, {})
|
||||||
for addr, l in dd.items():
|
for addr, l in dd.items():
|
||||||
|
|
Loading…
Add table
Reference in a new issue