@api_request
@reply_type([ProtocolMessageTypes.respond_proof_of_weight])
async def request_proof_of_weight(self, request: full_node_protocol.RequestProofOfWeight) -> Optional[Message]:
    if (self.full_node.weight_proof_handler is None):
        return None
    if (not self.full_node.blockchain.contains_block(request.tip)):
        self.log.error(f'got weight proof request for unknown peak {request.tip}')
        return None
    if (request.tip in self.full_node.pow_creation):
        event = self.full_node.pow_creation[request.tip]
        (await event.wait())
        wp = (await self.full_node.weight_proof_handler.get_proof_of_weight(request.tip))
    else:
        event = asyncio.Event()
        self.full_node.pow_creation[request.tip] = event
        wp = (await self.full_node.weight_proof_handler.get_proof_of_weight(request.tip))
        event.set()
    tips = list(self.full_node.pow_creation.keys())
    if (len(tips) > 4):
        for i in range(0, 4):
            self.full_node.pow_creation.pop(tips[i])
    if (wp is None):
        self.log.error(f'failed creating weight proof for peak {request.tip}')
        return None
    if ((self.full_node.full_node_store.serialized_wp_message_tip is not None) and (self.full_node.full_node_store.serialized_wp_message_tip == request.tip)):
        return self.full_node.full_node_store.serialized_wp_message
    message = make_msg(ProtocolMessageTypes.respond_proof_of_weight, full_node_protocol.RespondProofOfWeight(wp, request.tip))
    self.full_node.full_node_store.serialized_wp_message_tip = request.tip
    self.full_node.full_node_store.serialized_wp_message = message
    return message
@api_request
@reply_type([ProtocolMessageTypes.respond_proof_of_weight])
async def request_proof_of_weight(self, request: full_node_protocol.RequestProofOfWeight) -> Optional[Message]:
    if (self.full_node.weight_proof_handler is None):
        return None
    if (not self.full_node.blockchain.contains_block(request.tip)):
        self.log.error(f'got weight proof request for unknown peak {request.tip}')
        return None
    if (request.tip in self.full_node.pow_creation):
        event = self.full_node.pow_creation[request.tip]
        (await event.wait())
        wp = (await self.full_node.weight_proof_handler.get_proof_of_weight(request.tip))
    else:
        event = asyncio.Event()
        self.full_node.pow_creation[request.tip] = event
        wp = (await self.full_node.weight_proof_handler.get_proof_of_weight(request.tip))
        event.set()
    tips = list(self.full_node.pow_creation.keys())
    if (len(tips) > 4):
        for i in range(0, 4):
            self.full_node.pow_creation.pop(tips[i])
    if (wp is None):
        self.log.error(f'failed creating weight proof for peak {request.tip}')
        return None
    if ((self.full_node.full_node_store.serialized_wp_message_tip is not None) and (self.full_node.full_node_store.serialized_wp_message_tip == request.tip)):
        return self.full_node.full_node_store.serialized_wp_message
    message = make_msg(ProtocolMessageTypes.respond_proof_of_weight, full_node_protocol.RespondProofOfWeight(wp, request.tip))
    self.full_node.full_node_store.serialized_wp_message_tip = request.tip
    self.full_node.full_node_store.serialized_wp_message = message
    return message