Browse Source

Revert "Fix bug in detailed wallet sync relating to gap addrs."

This reverts commit 4b4f8c97f4.

Due to a flawed assumption where sometimes importing addresses does
take a significant amount of time. For example on machines with HDD
importing 1-2 addresses can last a second or two, and importing 60
addresses lasts about 30 seconds. The commit makes running a maker
impossible on such a machine.
master
chris-belcher 6 years ago
parent
commit
df57099c26
No known key found for this signature in database
GPG Key ID: EF734EA677F31129
  1. 9
      jmclient/jmclient/blockchaininterface.py
  2. 18
      jmclient/jmclient/wallet.py

9
jmclient/jmclient/blockchaininterface.py

@ -512,15 +512,7 @@ class BitcoinCoreInterface(BlockchainInterface):
self.wallet_synced = True self.wallet_synced = True
def sync_addresses(self, wallet, restart_cb=None): def sync_addresses(self, wallet, restart_cb=None):
# This more detailed version of wallet syncing must cover situations
# where the user has used the wallet on other Bitcoin Core instances
# and therefore the wallet label either does not have addresses
# imported, and/or, after the addresses are imported, they may not
# have the full history, since a rescan is required to discover
# the history of addresses before they were imported.
log.debug("requesting detailed wallet history") log.debug("requesting detailed wallet history")
wallet_name = self.get_wallet_name(wallet) wallet_name = self.get_wallet_name(wallet)
addresses, saved_indices = self._collect_addresses_init(wallet) addresses, saved_indices = self._collect_addresses_init(wallet)
@ -542,6 +534,7 @@ class BitcoinCoreInterface(BlockchainInterface):
used_addresses_gen = (tx['address'] used_addresses_gen = (tx['address']
for tx in self._yield_transactions(wallet_name) for tx in self._yield_transactions(wallet_name)
if tx['category'] == 'receive') if tx['category'] == 'receive')
used_indices = self._get_used_indices(wallet, used_addresses_gen) used_indices = self._get_used_indices(wallet, used_addresses_gen)
log.debug("got used indices: {}".format(used_indices)) log.debug("got used indices: {}".format(used_indices))
gap_limit_used = not self._check_gap_indices(wallet, used_indices) gap_limit_used = not self._check_gap_indices(wallet, used_indices)

18
jmclient/jmclient/wallet.py

@ -426,18 +426,12 @@ class BaseWallet(object):
privkey = self._get_priv_from_path(path)[0] privkey = self._get_priv_from_path(path)[0]
return hexlify(privkey).decode('ascii') return hexlify(privkey).decode('ascii')
def _get_addr_int_ext(self, internal, mixdepth, bci=None): def _get_addr_int_ext(self, get_script_func, mixdepth, bci=None):
script = self.get_internal_script(mixdepth) if internal else \ script = get_script_func(mixdepth)
self.get_external_script(mixdepth)
addr = self.script_to_addr(script) addr = self.script_to_addr(script)
if bci is not None and hasattr(bci, 'import_addresses'): if bci is not None and hasattr(bci, 'import_addresses'):
assert hasattr(bci, 'get_wallet_name') assert hasattr(bci, 'get_wallet_name')
# we aggressively import ahead of our index, so that when bci.import_addresses([addr], bci.get_wallet_name(self))
# detailed sync is needed in future, it will not find
# imports missing (and this operation costs nothing).
addrs_to_import = list(bci._collect_addresses_gap(
self, self.gaplimit))
bci.import_addresses(addrs_to_import, bci.get_wallet_name(self))
return addr return addr
def get_external_addr(self, mixdepth, bci=None): def get_external_addr(self, mixdepth, bci=None):
@ -449,7 +443,8 @@ class BaseWallet(object):
address into this blockchaininterface instance address into this blockchaininterface instance
(based on Bitcoin Core's model). (based on Bitcoin Core's model).
""" """
return self._get_addr_int_ext(False, mixdepth, bci=bci) return self._get_addr_int_ext(self.get_external_script, mixdepth,
bci=bci)
def get_internal_addr(self, mixdepth, bci=None): def get_internal_addr(self, mixdepth, bci=None):
""" """
@ -459,7 +454,8 @@ class BaseWallet(object):
address into this blockchaininterface instance address into this blockchaininterface instance
(based on Bitcoin Core's model). (based on Bitcoin Core's model).
""" """
return self._get_addr_int_ext(True, mixdepth, bci=bci) return self._get_addr_int_ext(self.get_internal_script, mixdepth,
bci=bci)
def get_external_script(self, mixdepth): def get_external_script(self, mixdepth):
return self.get_new_script(mixdepth, False) return self.get_new_script(mixdepth, False)

Loading…
Cancel
Save