Skip to content

Commit ef830fd

Browse files
JeremyRandSomberNight
authored andcommitted
Array headers: Refactor AuxPoW truncation
1 parent 264daec commit ef830fd

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

electrumx/server/session.py

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

21492149
# Covered by a checkpoint; truncate AuxPoW data
2150-
result['header'] = result['header'][:self.coin.TRUNCATED_HEADER_SIZE]
2150+
result['header'] = self.truncate_auxpow_single(result['header'])
21512151
return result
21522152

21532153
async def block_headers(self, start_height, count, cp_height=0):
@@ -2176,5 +2176,9 @@ async def block_headers(self, start_height, count, cp_height=0):
21762176
def truncate_auxpow_headers(self, headers):
21772177
result = []
21782178
for header in headers:
2179-
result.append(header[:self.coin.TRUNCATED_HEADER_SIZE])
2179+
result.append(self.truncate_auxpow_single(header))
21802180
return result
2181+
2182+
def truncate_auxpow_single(self, header: str):
2183+
# 2 hex chars per byte
2184+
return header[:2*self.coin.TRUNCATED_HEADER_SIZE]

0 commit comments

Comments
 (0)