async def send_membership(self, password, community, mstype): """ Send a membership document to a target community. Signal "document_broadcasted" is emitted at the end. :param str password: The account SigningKey password :param community: The community target of the membership document :param str mstype: The type of membership demand. "IN" to join, "OUT" to leave """ logging.debug("Send membership") blockid = await community.blockid() self_identity = await self._identities_registry.future_find(self.pubkey, community) selfcert = await self_identity.selfcert(community) membership = Membership(PROTOCOL_VERSION, community.currency, selfcert.pubkey, blockid, mstype, selfcert.uid, selfcert.timestamp, None) key = SigningKey(self.salt, password) membership.sign([key]) logging.debug("Membership : {0}".format(membership.signed_raw())) responses = await community.bma_access.broadcast(bma.blockchain.Membership, {}, {'membership': membership.signed_raw()}) result = (False, "") for r in responses: if r.status == 200: result = (True, (await r.json())) elif not result[0]: result = (False, (await r.text())) else: await r.release() return result
def send_membership(self, password, community, mstype): ''' Send a membership document to a target community :param str password: The account SigningKey password :param community: The community target of the membership document :param str mstype: The type of membership demand. "IN" to join, "OUT" to leave ''' self_ = Person.lookup(self.pubkey, community) selfcert = self_.selfcert(community) blockid = community.current_blockid() membership = Membership(PROTOCOL_VERSION, community.currency, selfcert.pubkey, blockid['number'], blockid['hash'], mstype, selfcert.uid, selfcert.timestamp, None) key = SigningKey(self.salt, password) membership.sign([key]) logging.debug("Membership : {0}".format(membership.signed_raw())) community.broadcast(bma.blockchain.Membership, {}, {'membership': membership.signed_raw()})