Browse Source
wallet: towards restoring previous performance 2
sqlite_db
SomberNight
6 years ago
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
3 changed files with
13 additions and
9 deletions
-
electrum/address_synchronizer.py
-
electrum/json_db.py
-
electrum/wallet.py
|
|
@ -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 |
|
|
|
|
|
|
|