tnetwork: handle one-block-long fork - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit eaf72aa9515bb3c09f68a483645dbeb96932616f DIR parent 0d05b84dc3234791d73f6aa098d7d799910943b4 HTML Author: SomberNight <somber.night@protonmail.com> Date: Sun, 29 Jul 2018 04:00:02 +0200 network: handle one-block-long fork also add fixme about incorrect behaviour in case of a fork height higher than our local chain tip Diffstat: M electrum/network.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) --- DIR diff --git a/electrum/network.py b/electrum/network.py t@@ -912,6 +912,9 @@ class Network(util.DaemonThread): next_height = height + 1 interface.blockchain.catch_up = interface.server elif chain: + # FIXME should await "initial chunk download". + # binary search will NOT do the correct thing if we don't yet + # have all headers up to the fork height interface.print_error("binary search") interface.mode = 'binary' interface.blockchain = chain t@@ -973,8 +976,10 @@ class Network(util.DaemonThread): interface.blockchain = b interface.print_error("new chain", b.checkpoint) interface.mode = 'catch_up' - next_height = interface.bad + 1 - interface.blockchain.catch_up = interface.server + maybe_next_height = interface.bad + 1 + if maybe_next_height <= interface.tip: + next_height = maybe_next_height + interface.blockchain.catch_up = interface.server else: assert bh == interface.good if interface.blockchain.catch_up is None and bh < interface.tip: