async def get_additions(self, peer: WSChiaConnection, block_i, additions) -> Optional[List[Coin]]: if len(additions) > 0: additions_request = RequestAdditions(block_i.height, block_i.header_hash, additions) additions_res: Optional[Union[RespondAdditions, RejectAdditionsRequest]] = await peer.request_additions( additions_request ) if additions_res is None: await peer.close() return None elif isinstance(additions_res, RespondAdditions): validated = self.validate_additions( additions_res.coins, additions_res.proofs, block_i.foliage_transaction_block.additions_root, ) if not validated: await peer.close() return None added_coins = [] for ph_coins in additions_res.coins: ph, coins = ph_coins added_coins.extend(coins) return added_coins elif isinstance(additions_res, RejectRemovalsRequest): await peer.close() return None return None else: return [] # No added coins
async def request_and_validate_additions(peer, height, header_hash, puzzle_hash, additions_root): additions_request = RequestAdditions(height, header_hash, [puzzle_hash]) additions_res: Optional[ Union[RespondAdditions, RejectAdditionsRequest]] = await peer.request_additions( additions_request) if additions_res is None or isinstance(additions_res, RejectAdditionsRequest): return False validated = validate_additions( additions_res.coins, additions_res.proofs, additions_root, ) return validated