commit 9b7102aed1d9de7f2684b0bbb94f5b9dc5622a04
parent 680e9a55523885e96e08cbe49dd5ac55aac52da0
Author: ThomasV <thomasv@electrum.org>
Date: Sat, 8 Jul 2017 16:45:09 +0200
make fork_threshold configurable, fix backward mode
Diffstat:
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/lib/network.py b/lib/network.py
@@ -867,7 +867,8 @@ class Network(util.DaemonThread):
interface.print_error("found connection at %d"% interface.good)
delta1 = interface.blockchain.height() - interface.good
delta2 = interface.tip - interface.good
- if delta1 > 10 and delta2 > 10:
+ threshold = self.config.get('fork_threshold', 5)
+ if delta1 > threshold and delta2 > threshold:
interface.print_error("chain split detected: %d (%d %d)"% (interface.good, delta1, delta2))
interface.blockchain.fork(interface.bad)
interface.blockchain = Blockchain(self.config, interface.bad)
@@ -886,7 +887,9 @@ class Network(util.DaemonThread):
self.notify('updated')
next_height = height + 1 if height < interface.tip else None
else:
- # go back, reorg
+ # go back
+ interface.mode = 'backward'
+ interface.bad = height
next_height = height - 1
if next_height is None: