simplify get_unfinished_blocks() (#17226)

This commit is contained in:
Arvid Norberg 2024-01-08 15:35:52 +01:00 committed by GitHub
parent 101f1aa9e4
commit c9e33f0e30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 14 deletions

View File

@ -178,8 +178,9 @@ class FullNodeStore:
return None
return result[2]
def get_unfinished_blocks(self) -> Dict[bytes32, Tuple[uint32, UnfinishedBlock, PreValidationResult]]:
return self.unfinished_blocks
# returns all unfinished blocks for the specified height
def get_unfinished_blocks(self, height: uint32) -> List[UnfinishedBlock]:
return [block for ub_height, block, _ in self.unfinished_blocks.values() if ub_height == height]
def clear_unfinished_blocks_below(self, height: uint32) -> None:
del_keys: List[bytes32] = []

View File

@ -556,18 +556,17 @@ class FullNodeRpcApi:
return {"headers": []}
response_headers: List[UnfinishedHeaderBlock] = []
for ub_height, block, _ in (self.service.full_node_store.get_unfinished_blocks()).values():
if ub_height == peak.height:
unfinished_header_block = UnfinishedHeaderBlock(
block.finished_sub_slots,
block.reward_chain_block,
block.challenge_chain_sp_proof,
block.reward_chain_sp_proof,
block.foliage,
block.foliage_transaction_block,
b"",
)
response_headers.append(unfinished_header_block)
for block in self.service.full_node_store.get_unfinished_blocks(peak.height):
unfinished_header_block = UnfinishedHeaderBlock(
block.finished_sub_slots,
block.reward_chain_block,
block.challenge_chain_sp_proof,
block.reward_chain_sp_proof,
block.foliage,
block.foliage_transaction_block,
b"",
)
response_headers.append(unfinished_header_block)
return {"headers": response_headers}
async def get_network_space(self, request: Dict[str, Any]) -> EndpointResult: