def _distribute_vesicle(self, vesicle, recipients=None):
        """
        Encrypt, sign and distribute vesicle to `recipients` using Myelin

        Args:
            vesicle (Vesicle): The message to transmit.
            recipients (List): List of Persona objects. If recipients is not
                empty, the Vesicle is encrypted and the key is transmitted for
                this list of Personas.

        Returns:
            Vesicle: The (signed and encrypted) Vesicle object
        """
        self.logger.debug("Distributing {} to {} recipients {}".format(
            vesicle,
            len(recipients) if recipients is not None else "0",
            "via Myelin" if app.config["ENABLE_MYELIN"] else ""))

        if not hasattr(vesicle, "author"):
            raise ValueError("Can't send Vesicle without defined author")

        if vesicle.encrypted():
            keycrypt = json.loads(vesicle.keycrypt)

            # First remove everyone from keycrypt that is not a current recipient
            keycrypt = json.loads(vesicle.keycrypt)
            remove_recipients = set(keycrypt.keys()) - set([r.id for r in recipients])
            for recipient_id in remove_recipients:
                if recipient_id != vesicle.author_id:  # Don't remove author!
                    del keycrypt[recipient_id]
            vesicle.keycrypt = json.dumps(keycrypt)

            # Then add the new recipients
            vesicle.add_recipients(recipients)

            self.logger.debug("{} was already encrypted: Modified keycrypt.".format(vesicle))
        else:
            vesicle.encrypt(recipients=recipients)

        try:
            vesicle.sign()
        except VesicleStateError:
            self.logger.info("{} was already signed".format(vesicle))

        if app.config["ENABLE_MYELIN"]:
            self.electrical.myelin_store(vesicle)

        return vesicle
dataset/ETHPy150Open ciex/souma/synapse/__init__.py/Synapse._distribute_vesicle/original