close connection if server sends invalid headers
This commit is contained in:
parent
94f7a87e47
commit
311f9eda17
|
@ -830,6 +830,9 @@ class Network(util.DaemonThread):
|
||||||
interface.bad_header = header
|
interface.bad_header = header
|
||||||
if interface.bad != interface.good + 1:
|
if interface.bad != interface.good + 1:
|
||||||
next_height = (interface.bad + interface.good) // 2
|
next_height = (interface.bad + interface.good) // 2
|
||||||
|
elif not interface.blockchain.can_connect(interface.bad_header, check_height=False):
|
||||||
|
self.connection_down(interface.server)
|
||||||
|
next_height = None
|
||||||
else:
|
else:
|
||||||
branch = self.blockchains.get(interface.bad)
|
branch = self.blockchains.get(interface.bad)
|
||||||
if branch is not None:
|
if branch is not None:
|
||||||
|
@ -853,14 +856,13 @@ class Network(util.DaemonThread):
|
||||||
next_height = None
|
next_height = None
|
||||||
if bh > interface.good:
|
if bh > interface.good:
|
||||||
if not interface.blockchain.check_header(interface.bad_header):
|
if not interface.blockchain.check_header(interface.bad_header):
|
||||||
if interface.blockchain.can_connect(interface.bad_header, check_height=False):
|
b = interface.blockchain.fork(interface.bad_header)
|
||||||
b = interface.blockchain.fork(interface.bad_header)
|
self.blockchains[interface.bad] = b
|
||||||
self.blockchains[interface.bad] = b
|
interface.blockchain = b
|
||||||
interface.blockchain = b
|
interface.print_error("new chain", b.checkpoint)
|
||||||
interface.print_error("new chain", b.checkpoint)
|
interface.mode = 'catch_up'
|
||||||
interface.mode = 'catch_up'
|
next_height = interface.bad + 1
|
||||||
next_height = interface.bad + 1
|
interface.blockchain.catch_up = interface.server
|
||||||
interface.blockchain.catch_up = interface.server
|
|
||||||
else:
|
else:
|
||||||
assert bh == interface.good
|
assert bh == interface.good
|
||||||
if interface.blockchain.catch_up is None and bh < interface.tip:
|
if interface.blockchain.catch_up is None and bh < interface.tip:
|
||||||
|
|
Loading…
Reference in New Issue