From 9dd1dc7876e9e6087655ffd0eed18a9129a05ff2 Mon Sep 17 00:00:00 2001 From: undeath Date: Tue, 7 Aug 2018 16:11:09 +0200 Subject: [PATCH] fix wallet sync in fast mode --- jmclient/jmclient/blockchaininterface.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/jmclient/jmclient/blockchaininterface.py b/jmclient/jmclient/blockchaininterface.py index d5d7f8e..565eacc 100644 --- a/jmclient/jmclient/blockchaininterface.py +++ b/jmclient/jmclient/blockchaininterface.py @@ -6,6 +6,7 @@ import random import sys import time import binascii +from copy import deepcopy from decimal import Decimal from twisted.internet import reactor, task @@ -463,13 +464,22 @@ class BitcoinCoreInterface(BlockchainInterface): BATCH_SIZE = 100 MAX_ITERATIONS = 20 + current_indices = deepcopy(saved_indices) for j in range(MAX_ITERATIONS): if not remaining_used_addresses: break for addr in \ self._collect_addresses_gap(wallet, gap_limit=BATCH_SIZE): 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: + self._rewind_wallet_indices(wallet, saved_indices, saved_indices) raise Exception("Failed to sync in fast mode after 20 batches; " "please re-try wallet sync without --fast flag.")