Пример #1
0
    def handle_message_lockedtransfer(raiden: RaidenService,
                                      message: LockedTransfer) -> None:
        secrethash = message.lock.secrethash
        # We must check if the secret was registered against the latest block,
        # even if the block is forked away and the transaction that registers
        # the secret is removed from the blockchain. The rationale here is that
        # someone else does know the secret, regardless of the chain state, so
        # the node must not use it to start a payment.
        #
        # For this particular case, it's preferable to use `latest` instead of
        # having a specific block_hash, because it's preferable to know if the secret`
        # was ever known, rather than having a consistent view of the blockchain.
        registered = raiden.default_secret_registry.is_secret_registered(
            secrethash=secrethash, block_identifier="latest")
        if registered:
            log.warning(
                f"Ignoring received locked transfer with secrethash {pex(secrethash)} "
                f"since it is already registered in the secret registry")
            return

        # TODO marcosmartinez7: unimplemented mediated transfer for light clients
        is_handled_light_client = LightClientService.is_handled_lc(
            to_checksum_address(message.recipient), raiden.wal)

        if message.target == raiden.address:
            raiden.target_mediated_transfer(message)
        elif is_handled_light_client:
            raiden.target_mediated_transfer_light(message)
        else:
            raiden.mediate_mediated_transfer(message)