mirror of
https://github.com/Chia-Network/chia-blockchain.git
synced 2024-09-11 18:58:59 +03:00
simplify get_unfinished_blocks() (#17226)
This commit is contained in:
parent
101f1aa9e4
commit
c9e33f0e30
@ -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] = []
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user