Skip to content

Commit ce7bb41

Browse files
JeremyRandSomberNight
authored andcommitted
Array headers: Refactor AuxPoW truncation
1 parent bbd3e06 commit ce7bb41

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/electrumx/server/session.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1985,7 +1985,7 @@ async def block_header(self, height, cp_height=0):
19851985
return result
19861986

19871987
# Covered by a checkpoint; truncate AuxPoW data
1988-
result['header'] = result['header'][:self.coin.TRUNCATED_HEADER_SIZE]
1988+
result['header'] = self.truncate_auxpow_single(result['header'])
19891989
return result
19901990

19911991
async def block_headers(self, start_height, count, cp_height=0):
@@ -2014,9 +2014,13 @@ async def block_headers(self, start_height, count, cp_height=0):
20142014
def truncate_auxpow_headers(self, headers):
20152015
result = []
20162016
for header in headers:
2017-
result.append(header[:self.coin.TRUNCATED_HEADER_SIZE])
2017+
result.append(self.truncate_auxpow_single(header))
20182018
return result
20192019

2020+
def truncate_auxpow_single(self, header: str):
2021+
# 2 hex chars per byte
2022+
return header[:2*self.coin.TRUNCATED_HEADER_SIZE]
2023+
20202024

20212025
class NameIndexElectrumX(ElectrumX):
20222026
def set_request_handlers(self, ptuple):

0 commit comments

Comments
 (0)