Clarify truncation behaviour of get_chunk in docs

This commit is contained in:
Neil Booth 2018-03-03 17:45:55 +08:00
parent 49ee008346
commit 7823129526
2 changed files with 24 additions and 1 deletions

View File

@ -388,7 +388,10 @@ bandwidth-intensive request.
**Response**
The binary block headers, as hexadecimal strings, in order
concatenated together.
concatenated together. As many as headers as are available at
starting height 2016 * index will be returned; this may range from
0 to 2016.
blockchain.estimatefee

View File

@ -254,6 +254,26 @@ class ElectrumX(SessionBase):
'''Returns a dictionary of server features.'''
return self.env.server_features()
def block_headers(self, start_height, count):
'''Return concatenated block headers as hex for the main chain;
count headers starting at start_height.
start_height and count must be non-negative integers.'''
start_height = self.controller.non_negative_integer(start_height)
count = self.controller.non_negative_integer(count)
return self.controller.block_headers(start_height, count).hex()
def block_get_chunk(self, index):
'''Return a chunk of block headers as a hexadecimal string.
index: the chunk index'''
index = self.controller.non_negative_integer(index)
chunk_size = self.coin.CHUNK_SIZE
start_height = index * chunk_size
count = chunk_size
return self.controller.block_headers(start_height, count).hex()
def block_get_chunk(self, index):
'''Return a chunk of block headers as a hexadecimal string.