URI: 
       tnetwork: "switch unwanted fork" should check what fork we are on.. - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 0e59bc1bc589222d00d53de3e2220ec06784a421
   DIR parent 1af225015a19e0697f3ca31535d74f6f646ea7ac
  HTML Author: SomberNight <somber.night@protonmail.com>
       Date:   Sun, 14 Oct 2018 04:23:10 +0200
       
       network: "switch unwanted fork" should check what fork we are on..
       
       follow-up #4767
       
       Diffstat:
         M electrum/network.py                 |       4 +++-
       
       1 file changed, 3 insertions(+), 1 deletion(-)
       ---
   DIR diff --git a/electrum/network.py b/electrum/network.py
       t@@ -533,13 +533,15 @@ class Network(PrintError):
                """If auto_connect and main interface is not on preferred fork,
                try to switch to preferred fork.
                """
       -        if not self.auto_connect:
       +        if not self.auto_connect or not self.interface:
                    return
                with self.interfaces_lock: interfaces = list(self.interfaces.values())
                # try to switch to preferred fork
                if self._blockchain_preferred_block:
                    pref_height = self._blockchain_preferred_block['height']
                    pref_hash   = self._blockchain_preferred_block['hash']
       +            if self.interface.blockchain.check_hash(pref_height, pref_hash):
       +                return  # already on preferred fork
                    filtered = list(filter(lambda iface: iface.blockchain.check_hash(pref_height, pref_hash),
                                           interfaces))
                    if filtered: