electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit c3615d0aa7d6add315e0c80e4d40ecd304580315
parent ab5a9f3ce461040e52bf3caca376a26f5ff9d0c3
Author: ThomasV <thomasv@electrum.org>
Date:   Thu, 20 Jul 2017 11:36:59 +0200

fix: rename files affected by chain swap

Diffstat:
Mlib/blockchain.py | 10+++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lib/blockchain.py b/lib/blockchain.py @@ -184,7 +184,6 @@ class Blockchain(util.PrintError): def swap_with_parent(self): self.print_error("swap", self.checkpoint, self.parent.checkpoint) - assert self.size() == self.get_branch_size() parent = self.parent checkpoint = self.checkpoint size = parent.get_branch_size() @@ -201,9 +200,18 @@ class Blockchain(util.PrintError): with open(parent.path(), 'rb+') as f: f.seek((checkpoint - parent.checkpoint)*80) f.write(my_data) + # store file path + for b in blockchains.values(): + b.old_path = b.path() # swap parameters self.parent = parent.parent; parent.parent = self self.checkpoint = parent.checkpoint; parent.checkpoint = checkpoint + # move files + for b in blockchains.values(): + if b in [self, parent]: continue + if b.old_path != b.path(): + self.print_error("renaming", b.old_path, b.path()) + os.rename(b.old_path, b.path()) # update pointers blockchains[self.checkpoint] = self blockchains[parent.checkpoint] = parent