Merge #12861: [tests] Stop feature_block.py from blowing up memory.

89fe5feea2 [tests] Stop feature_block.py from blowing up memory. (John Newbery)

Pull request description:

  The new P2PDataStore class was sending full blocks in headers messages,
  which meant that calls to send_blocks_and_test() would blow up memory if
  called with a large number of blocks. Fix that by only sending headers
  in headers messages.

  This means that python should use just over 1GB for feature_block.py (with bitcoind also using just over 1GB). That's the same as before the feature_block.py refactor.

Tree-SHA512: 796ea35584748ceb7b8fa36c732a461fb924dafe0b4c52d3eccf21a00fbdb65aef41ce1d91f027aad50cde6df5d30e985aaef474cb743975c06762975469cbbb
This commit is contained in:
MarcoFalke 2018-04-02 17:40:16 -04:00
commit c564424d98
No known key found for this signature in database
GPG Key ID: D2EA4850E7528B25
1 changed files with 2 additions and 2 deletions

View File

@ -498,7 +498,7 @@ class P2PDataStore(P2PInterface):
# as we go.
prev_block_hash = headers_list[-1].hashPrevBlock
if prev_block_hash in self.block_store:
prev_block_header = self.block_store[prev_block_hash]
prev_block_header = CBlockHeader(self.block_store[prev_block_hash])
headers_list.append(prev_block_header)
if prev_block_header.sha256 == hash_stop:
# if this is the hashstop header, stop here
@ -539,7 +539,7 @@ class P2PDataStore(P2PInterface):
self.block_store[block.sha256] = block
self.last_block_hash = block.sha256
self.send_message(msg_headers([blocks[-1]]))
self.send_message(msg_headers([CBlockHeader(blocks[-1])]))
if request_block:
wait_until(lambda: blocks[-1].sha256 in self.getdata_requests, timeout=timeout, lock=mininode_lock)