mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-31 17:31:36 +00:00
wallet: towards restoring previous performance 2
This commit is contained in:
parent
8ae6ddcc00
commit
514d0ae958
3 changed files with 13 additions and 9 deletions
|
@ -91,7 +91,7 @@ class AddressSynchronizer(PrintError):
|
|||
self.remove_local_transactions_we_dont_have()
|
||||
|
||||
def is_mine(self, address):
|
||||
return address in self.db.get_history()
|
||||
return self.db.is_addr_in_history(address)
|
||||
|
||||
def get_addresses(self):
|
||||
return sorted(self.db.get_history())
|
||||
|
@ -160,7 +160,7 @@ class AddressSynchronizer(PrintError):
|
|||
self.storage.write()
|
||||
|
||||
def add_address(self, address):
|
||||
if address not in self.db.get_history():
|
||||
if not self.db.get_addr_history(address):
|
||||
self.db.history[address] = []
|
||||
self.set_up_to_date(False)
|
||||
if self.synchronizer:
|
||||
|
|
|
@ -607,6 +607,10 @@ class JsonDB(PrintError):
|
|||
def get_history(self):
|
||||
return list(self.history.keys())
|
||||
|
||||
def is_addr_in_history(self, addr):
|
||||
# does not mean history is non-empty!
|
||||
return addr in self.history
|
||||
|
||||
@locked
|
||||
def get_addr_history(self, addr):
|
||||
return self.history.get(addr, [])
|
||||
|
|
|
@ -1575,10 +1575,10 @@ class Deterministic_Wallet(Abstract_Wallet):
|
|||
|
||||
def num_unused_trailing_addresses(self, addresses):
|
||||
k = 0
|
||||
for a in addresses[::-1]:
|
||||
if a in self.db.get_history():
|
||||
for addr in addresses[::-1]:
|
||||
if self.db.get_addr_history(addr):
|
||||
break
|
||||
k = k + 1
|
||||
k += 1
|
||||
return k
|
||||
|
||||
def min_acceptable_gap(self):
|
||||
|
@ -1587,12 +1587,12 @@ class Deterministic_Wallet(Abstract_Wallet):
|
|||
nmax = 0
|
||||
addresses = self.get_receiving_addresses()
|
||||
k = self.num_unused_trailing_addresses(addresses)
|
||||
for a in addresses[0:-k]:
|
||||
if a in self.db.get_history():
|
||||
for addr in addresses[0:-k]:
|
||||
if self.db.get_addr_history(addr):
|
||||
n = 0
|
||||
else:
|
||||
n += 1
|
||||
if n > nmax: nmax = n
|
||||
nmax = max(nmax, n)
|
||||
return nmax + 1
|
||||
|
||||
def load_addresses(self):
|
||||
|
@ -1647,7 +1647,7 @@ class Deterministic_Wallet(Abstract_Wallet):
|
|||
return False
|
||||
prev_addresses = addr_list[max(0, i - limit):max(0, i)]
|
||||
for addr in prev_addresses:
|
||||
if addr in self.db.get_history():
|
||||
if self.db.get_addr_history(addr):
|
||||
return False
|
||||
return True
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue