Browse Source

fix wallet sync in fast mode

master
undeath 7 years ago
parent
commit
9dd1dc7876
  1. 10
      jmclient/jmclient/blockchaininterface.py

10
jmclient/jmclient/blockchaininterface.py

@ -6,6 +6,7 @@ import random
import sys import sys
import time import time
import binascii import binascii
from copy import deepcopy
from decimal import Decimal from decimal import Decimal
from twisted.internet import reactor, task from twisted.internet import reactor, task
@ -463,13 +464,22 @@ class BitcoinCoreInterface(BlockchainInterface):
BATCH_SIZE = 100 BATCH_SIZE = 100
MAX_ITERATIONS = 20 MAX_ITERATIONS = 20
current_indices = deepcopy(saved_indices)
for j in range(MAX_ITERATIONS): for j in range(MAX_ITERATIONS):
if not remaining_used_addresses: if not remaining_used_addresses:
break break
for addr in \ for addr in \
self._collect_addresses_gap(wallet, gap_limit=BATCH_SIZE): self._collect_addresses_gap(wallet, gap_limit=BATCH_SIZE):
remaining_used_addresses.discard(addr) remaining_used_addresses.discard(addr)
# increase wallet indices for next iteration
for md in current_indices:
current_indices[md][0] += BATCH_SIZE
current_indices[md][1] += BATCH_SIZE
self._rewind_wallet_indices(wallet, current_indices,
current_indices)
else: else:
self._rewind_wallet_indices(wallet, saved_indices, saved_indices)
raise Exception("Failed to sync in fast mode after 20 batches; " raise Exception("Failed to sync in fast mode after 20 batches; "
"please re-try wallet sync without --fast flag.") "please re-try wallet sync without --fast flag.")

Loading…
Cancel
Save