Skip to content

Commit 4955402

Browse files
JeremyRandSomberNight
authored andcommitted
Array headers: Refactor AuxPoW truncation
1 parent 4390cf3 commit 4955402

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
@@ -1976,7 +1976,7 @@ async def block_header(self, height, cp_height=0):
19761976
return result
19771977

19781978
# Covered by a checkpoint; truncate AuxPoW data
1979-
result['header'] = result['header'][:self.coin.TRUNCATED_HEADER_SIZE]
1979+
result['header'] = self.truncate_auxpow_single(result['header'])
19801980
return result
19811981

19821982
async def block_headers(self, start_height, count, cp_height=0):
@@ -2005,9 +2005,13 @@ async def block_headers(self, start_height, count, cp_height=0):
20052005
def truncate_auxpow_headers(self, headers):
20062006
result = []
20072007
for header in headers:
2008-
result.append(header[:self.coin.TRUNCATED_HEADER_SIZE])
2008+
result.append(self.truncate_auxpow_single(header))
20092009
return result
20102010

2011+
def truncate_auxpow_single(self, header: str):
2012+
# 2 hex chars per byte
2013+
return header[:2*self.coin.TRUNCATED_HEADER_SIZE]
2014+
20112015

20122016
class NameIndexElectrumX(ElectrumX):
20132017
def set_request_handlers(self, ptuple):

0 commit comments

Comments
 (0)