URI: 
       tfix: swap parent - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 7a8f337d2804a4d2c4eab798085182ce1d106b01
   DIR parent 0891798d1b20a748beffe28e683477d465e8d9b7
  HTML Author: ThomasV <thomasv@electrum.org>
       Date:   Wed, 19 Jul 2017 14:26:44 +0200
       
       fix: swap parent
       
       Diffstat:
         M lib/blockchain.py                   |      11 ++++++-----
       
       1 file changed, 6 insertions(+), 5 deletions(-)
       ---
   DIR diff --git a/lib/blockchain.py b/lib/blockchain.py
       t@@ -119,7 +119,7 @@ class Blockchain(util.PrintError):
                return header_hash == self.get_hash(height)
        
            def fork(parent, checkpoint):
       -        self = Blockchain(parent.config, checkpoint, blockchains[parent.checkpoint])
       +        self = Blockchain(parent.config, checkpoint, parent)
                # create file
                open(self.path(), 'w+').close()
                return self
       t@@ -199,7 +199,7 @@ class Blockchain(util.PrintError):
                    f.seek((checkpoint - parent.checkpoint)*80)
                    f.write(my_data)
                # swap parameters
       -        self.parent = parent.parent; parent.parent = parent
       +        self.parent = parent.parent; parent.parent = self
                self.checkpoint = parent.checkpoint; parent.checkpoint = checkpoint
                # update pointers
                blockchains[self.checkpoint] = self
       t@@ -219,8 +219,11 @@ class Blockchain(util.PrintError):
                    self.swap_with_parent()
        
            def read_header(self, height):
       +        assert self.parent != self
                if height < self.checkpoint:
                    return self.parent.read_header(height)
       +        if height > self.height():
       +            return
                delta = height - self.checkpoint
                name = self.path()
                if os.path.exists(name):
       t@@ -228,9 +231,7 @@ class Blockchain(util.PrintError):
                    f.seek(delta * 80)
                    h = f.read(80)
                    f.close()
       -            if len(h) == 80:
       -                h = deserialize_header(h, height)
       -                return h
       +        return deserialize_header(h, height)
        
            def get_hash(self, height):
                return bitcoin.GENESIS if height == 0 else hash_header(self.read_header(height))