1
0

interface: "block.headers": nicer error if server uses too low 'max'

related 4ff6a9c4f0
This commit is contained in:
SomberNight
2021-02-18 20:40:38 +01:00
parent d906819b03
commit 1ee99cf9c4

View File

@@ -608,6 +608,9 @@ class Interface(Logger):
assert_hex_str(res['hex'])
if len(res['hex']) != HEADER_SIZE * 2 * res['count']:
raise RequestCorrupted('inconsistent chunk hex and count')
# we never request more than 2016 headers, but we enforce those fit in a single response
if res['max'] < 2016:
raise RequestCorrupted(f"server uses too low 'max' count for block.headers: {res['max']} < 2016")
if res['count'] != size:
raise RequestCorrupted(f"expected {size} headers but only got {res['count']}")
conn = self.blockchain.connect_chunk(index, res['hex'])