Skip to content

Commit 0608279

Browse files
JeremyRandSomberNight
authored andcommitted
Array headers: Refactor AuxPoW truncation
1 parent 81717bb commit 0608279

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/electrumx/server/session.py

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

19961996
# Covered by a checkpoint; truncate AuxPoW data
1997-
result['header'] = result['header'][:self.coin.TRUNCATED_HEADER_SIZE]
1997+
result['header'] = self.truncate_auxpow_single(result['header'])
19981998
return result
19991999

20002000
async def block_headers(self, start_height, count, cp_height=0):
@@ -2023,9 +2023,13 @@ async def block_headers(self, start_height, count, cp_height=0):
20232023
def truncate_auxpow_headers(self, headers):
20242024
result = []
20252025
for header in headers:
2026-
result.append(header[:self.coin.TRUNCATED_HEADER_SIZE])
2026+
result.append(self.truncate_auxpow_single(header))
20272027
return result
20282028

2029+
def truncate_auxpow_single(self, header: str):
2030+
# 2 hex chars per byte
2031+
return header[:2*self.coin.TRUNCATED_HEADER_SIZE]
2032+
20292033

20302034
class NameIndexElectrumX(ElectrumX):
20312035
def set_request_handlers(self, ptuple):

0 commit comments

Comments
 (0)