@@ -1994,26 +1994,30 @@ async def block_header(self, height, cp_height=0):
19941994 return result
19951995
19961996 # Covered by a checkpoint; truncate AuxPoW data
1997- result ['header' ] = self . truncate_auxpow ( result ['header' ], height )
1997+ result ['header' ] = result ['header' ][: self . coin . TRUNCATED_HEADER_SIZE ]
19981998 return result
19991999
20002000 async def block_headers (self , start_height , count , cp_height = 0 ):
2001- result = await super ().block_headers (start_height , count , cp_height )
2002-
20032001 # Older protocol versions don't truncate AuxPoW
20042002 if self .protocol_tuple < (1 , 4 , 1 ):
2005- return result
2003+ return await super (). block_headers ( start_height , count , cp_height )
20062004
20072005 # Not covered by a checkpoint; return full AuxPoW data
20082006 if cp_height == 0 :
2009- return result
2007+ return await super ().block_headers (start_height , count , cp_height )
2008+
2009+ result = await super ().block_headers_array (start_height , count , cp_height )
20102010
20112011 # Covered by a checkpoint; truncate AuxPoW data
2012+ result ['headers' ] = self .truncate_auxpow_headers (result ['headers' ])
2013+
2014+ # Return headers in array form
20122015 if self .protocol_tuple >= (1 , 6 ):
2013- result ['headers' ] = self .truncate_auxpow_headers (result ['headers' ])
2014- return
2016+ return result
20152017
2016- result ['hex' ] = self .truncate_auxpow (result ['hex' ], start_height )
2018+ # Return headers in concatenated form
2019+ result ['hex' ] = '' .join (result ['headers' ])
2020+ del result ['headers' ]
20172021 return result
20182022
20192023 def truncate_auxpow_headers (self , headers ):
@@ -2022,19 +2026,6 @@ def truncate_auxpow_headers(self, headers):
20222026 result .append (header [:self .coin .TRUNCATED_HEADER_SIZE ])
20232027 return result
20242028
2025- def truncate_auxpow (self , headers_full_hex , start_height ):
2026- height = start_height
2027- headers_full = util .hex_to_bytes (headers_full_hex )
2028- cursor = 0
2029- headers = bytearray ()
2030-
2031- while cursor < len (headers_full ):
2032- headers += headers_full [cursor :cursor + self .coin .TRUNCATED_HEADER_SIZE ]
2033- cursor += self .db .dynamic_header_len (height )
2034- height += 1
2035-
2036- return headers .hex ()
2037-
20382029
20392030class NameIndexElectrumX (ElectrumX ):
20402031 def set_request_handlers (self , ptuple ):
0 commit comments