mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-03 12:30:07 +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()
|
self.remove_local_transactions_we_dont_have()
|
||||||
|
|
||||||
def is_mine(self, address):
|
def is_mine(self, address):
|
||||||
return address in self.db.get_history()
|
return self.db.is_addr_in_history(address)
|
||||||
|
|
||||||
def get_addresses(self):
|
def get_addresses(self):
|
||||||
return sorted(self.db.get_history())
|
return sorted(self.db.get_history())
|
||||||
|
@ -160,7 +160,7 @@ class AddressSynchronizer(PrintError):
|
||||||
self.storage.write()
|
self.storage.write()
|
||||||
|
|
||||||
def add_address(self, address):
|
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.db.history[address] = []
|
||||||
self.set_up_to_date(False)
|
self.set_up_to_date(False)
|
||||||
if self.synchronizer:
|
if self.synchronizer:
|
||||||
|
|
|
@ -607,6 +607,10 @@ class JsonDB(PrintError):
|
||||||
def get_history(self):
|
def get_history(self):
|
||||||
return list(self.history.keys())
|
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
|
@locked
|
||||||
def get_addr_history(self, addr):
|
def get_addr_history(self, addr):
|
||||||
return self.history.get(addr, [])
|
return self.history.get(addr, [])
|
||||||
|
|
|
@ -1575,10 +1575,10 @@ class Deterministic_Wallet(Abstract_Wallet):
|
||||||
|
|
||||||
def num_unused_trailing_addresses(self, addresses):
|
def num_unused_trailing_addresses(self, addresses):
|
||||||
k = 0
|
k = 0
|
||||||
for a in addresses[::-1]:
|
for addr in addresses[::-1]:
|
||||||
if a in self.db.get_history():
|
if self.db.get_addr_history(addr):
|
||||||
break
|
break
|
||||||
k = k + 1
|
k += 1
|
||||||
return k
|
return k
|
||||||
|
|
||||||
def min_acceptable_gap(self):
|
def min_acceptable_gap(self):
|
||||||
|
@ -1587,12 +1587,12 @@ class Deterministic_Wallet(Abstract_Wallet):
|
||||||
nmax = 0
|
nmax = 0
|
||||||
addresses = self.get_receiving_addresses()
|
addresses = self.get_receiving_addresses()
|
||||||
k = self.num_unused_trailing_addresses(addresses)
|
k = self.num_unused_trailing_addresses(addresses)
|
||||||
for a in addresses[0:-k]:
|
for addr in addresses[0:-k]:
|
||||||
if a in self.db.get_history():
|
if self.db.get_addr_history(addr):
|
||||||
n = 0
|
n = 0
|
||||||
else:
|
else:
|
||||||
n += 1
|
n += 1
|
||||||
if n > nmax: nmax = n
|
nmax = max(nmax, n)
|
||||||
return nmax + 1
|
return nmax + 1
|
||||||
|
|
||||||
def load_addresses(self):
|
def load_addresses(self):
|
||||||
|
@ -1647,7 +1647,7 @@ class Deterministic_Wallet(Abstract_Wallet):
|
||||||
return False
|
return False
|
||||||
prev_addresses = addr_list[max(0, i - limit):max(0, i)]
|
prev_addresses = addr_list[max(0, i - limit):max(0, i)]
|
||||||
for addr in prev_addresses:
|
for addr in prev_addresses:
|
||||||
if addr in self.db.get_history():
|
if self.db.get_addr_history(addr):
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue