1
0

wallet: save num_parents of utxos in wallet file.

fixes #8361
This commit is contained in:
ThomasV
2023-05-02 08:54:00 +02:00
parent 6d392a67f9
commit 8a25d59ba6

View File

@@ -339,6 +339,7 @@ class Abstract_Wallet(ABC, Logger, EventListener):
self._receive_requests = db.get_dict('payment_requests') # type: Dict[str, Request]
self._invoices = db.get_dict('invoices') # type: Dict[str, Invoice]
self._reserved_addresses = set(db.get('reserved_addresses', []))
self._num_parents = db.get_dict('num_parents')
self._freeze_lock = threading.RLock() # for mutating/iterating frozen_{addresses,coins}
@@ -472,6 +473,7 @@ class Abstract_Wallet(ABC, Logger, EventListener):
def clear_tx_parents_cache(self):
with self.lock, self.transaction_lock:
self._tx_parents_cache.clear()
self._num_parents.clear()
self._last_full_history = None
@event_listener
@@ -887,7 +889,9 @@ class Abstract_Wallet(ABC, Logger, EventListener):
def get_num_parents(self, txid: str) -> Optional[int]:
if not self.is_up_to_date():
return
return len(self.get_tx_parents(txid))
if txid not in self._num_parents:
self._num_parents[txid] = len(self.get_tx_parents(txid))
return self._num_parents[txid]
def get_tx_parents(self, txid: str) -> Dict[str, Tuple[List[str], List[str]]]:
"""