Return true if the instance id of message corresponds to a correct
        replica.

        :param msg: the node message to validate
        :return:
496757
def msgHasAcceptableInstId(self, msg, frm) -> bool:
        
        # TODO: refactor this! this should not do anything except checking!
        instId = getattr(msg, f.INST_ID.nm, None)
        if not (isinstance(instId, int) and instId >= 0):
            return False
        if instId >= self.requiredNumberOfInstances:
            if instId not in self.msgsForFutureReplicas:
                self.msgsForFutureReplicas[instId] = deque()
            self.msgsForFutureReplicas[instId].append((msg, frm))
            logger.debug("{} queueing message {} for future protocol instance {}".format(self, msg, instId))
            return False
        return True
1243311
def delete_message(self, message):
        

        message_id = message.object_id if isinstance(message,
                                                     Message) else message

        if message_id is None:
            raise RuntimeError('Provide a valid Message or a message id')

        url = self.build_url(
            self._endpoints.get('message').format(id=message_id))

        response = self.con.delete(url)

        return bool(response)
1230141
def _error_message(self, selector):
        
        is_replica_set = self._description.topology_type in (
            TOPOLOGY_TYPE.ReplicaSetWithPrimary,
            TOPOLOGY_TYPE.ReplicaSetNoPrimary)

        if is_replica_set:
            server_plural = 'replica set members'
        elif self._description.topology_type == TOPOLOGY_TYPE.Sharded:
            server_plural = 'mongoses'
        else:
            server_plural = 'servers'

        if self._description.known_servers:
            # We've connected, but no servers match the selector.
            if selector is writable_server_selector:
                if is_replica_set:
                    return 'No primary available for writes'
                else:
                    return 'No %s available for writes' % server_plural
            else:
                return 'No %s match selector "%s"' % (server_plural, selector)
        else:
            addresses = list(self._description.server_descriptions())
            servers = list(self._description.server_descriptions().values())
            if not servers:
                if is_replica_set:
                    # We removed all servers because of the wrong setName?
                    return 'No %s available for replica set name "%s"' % (
                        server_plural, self._settings.replica_set_name)
                else:
                    return 'No %s available' % server_plural

            # 1 or more servers, all Unknown. Are they unknown for one reason?
            error = servers[0].error
            same = all(server.error == error for server in servers[1:])
            if same:
                if error is None:
                    # We're still discovering.
                    return 'No %s found yet' % server_plural

                if (is_replica_set and not
                        set(addresses).intersection(self._seed_addresses)):
                    # We replaced our seeds with new hosts but can't reach any.
                    return (
                        'Could not reach any servers in %s. Replica set is'
                        ' configured with internal hostnames or IPs?' %
                        addresses)

                return str(error)
            else:
                return ','.join(str(server.error) for server in servers
                                if server.error)
1146142
def message(self, msg):
        
        for broker in self.message_brokers:
            try:
                broker(msg)
            except Exception as exc:
                utils.error(exc)
825233
def is_valid(self):
        '''
        
        '''

        valid = super(RegistrationContactForm,self).is_valid()
        msgs = messages.get_messages(self._request)

        # We only want validation messages to show up once, so pop messages that have already show up
        # before checking to see if any messages remain to be shown.
        prior_messages = self._session.pop('prior_messages',[])
        remaining_messages = []

        for m in msgs:
            m_dict = {'message': m.message, 'level': m.level, 'extra_tags': m.extra_tags}
            if m_dict not in prior_messages:
                remaining_messages.append(m_dict)

        if remaining_messages:
            self._session['prior_messages'] = remaining_messages
            self._request.session.modified = True
            return False
        return valid
1056444
def mget(msg_id, keys)
      keys = keys.map{|suffix| key(msg_id, suffix)}
      with_failover { redis.mget(*keys) }
    end
476904
def found_duplicate?(msg_data)
      return false unless msg_data && msg_data[:queue]
      timeout = self.queue_timeout(msg_data)
      begin
        !@memcached_client.add(msg_data[:id], "1",timeout)
      rescue StandardError => e
        if @dupe_on_cache_failure
          Chore.logger.error "Error accessing duplicate cache server. Assuming message is a duplicate. #{e}\n#{e.backtrace * "\n"}"
          true
        else
          Chore.logger.error "Error accessing duplicate cache server. Assuming message is not a duplicate. #{e}\n#{e.backtrace * "\n"}"
          false
        end
      end
    end
1002421
function verify(postedMessage) {
		if (
			// Check incoming message is valid
			typeof postedMessage === 'object' &&
			typeof postedMessage.uuid === 'string' &&
			postedMessage._respondable === true
		) {
			var messageSource = _getSource();
			return (
				// Check the version matches
				postedMessage._source === messageSource ||
				// Allow free communication with axe test
				postedMessage._source === 'axeAPI.x.y.z' ||
				messageSource === 'axeAPI.x.y.z'
			);
		}
		return false;
	}
1256723
def CopyFrom(self, other_msg):
    
    if self is other_msg:
      return
    self.Clear()
    self.MergeFrom(other_msg)
848172
function isSituationalChessMessage(msg) {
    if (!msg.value || !msg.value.content) {
      return false;
    }

    const relevantMessageTypes = [
      'chess_invite',
      'chess_invite_accept',
      'chess_move',
      'chess_game_end'];

    const messageType = msg.value.content.type;
    const isSituationMsg = relevantMessageTypes.find(m => m === messageType);
    return isSituationMsg !== undefined;
  }
488915
def verify(value, msg):
    
    return bool(value) and \
           converts_to_proto(value, msg) and \
           successfuly_encodes(msg) and \
           special_typechecking(value, msg)
1301572
def _messageFromSender(self, sender, messageID):
        
        return self.store.findUnique(
            _QueuedMessage,
            AND(_QueuedMessage.senderUsername == sender.localpart,
                _QueuedMessage.senderDomain == sender.domain,
                _QueuedMessage.messageID == messageID),
            default=None)
433789
def IsValidForDescriptor(self, message_descriptor):
    """"""
    for path in self.paths:
      if not _IsValidPath(message_descriptor, path):
        return False
    return True
36894
def check(self, defn, msg=None):
        
        # Check enum does not contain boolean keys
        if (defn.slice().start != self.prevstop):
            self.messages.append(self.msg % str(defn.name))
            # TODO self.messages.append("TBD location message")
            self.valid = False

        self.prevstop = defn.slice().stop
10634
def verify(self, sig, msg):
        '''
        
        '''
        return lib.ed25519_VerifySignature(
            sig, self.__verifyingkey, msg, len(msg)) == 1
1204531
protected function isSubjectValid(CommitMessage $msg) : bool
    {
        return !$this->containsBlacklistedWord($this->blacklist['subject'], $msg->getSubject());
    }
1240489
public boolean evaluateMessage(
    Selector selectorTree,
    Selector discriminatorTree,
    SIBusMessage msg)
  { 
    if (tc.isEntryEnabled())
      SibTr.entry(tc, "evaluateMessage", new Object[] { selectorTree, discriminatorTree, msg });

    boolean ret = mpm.evaluateMessage(selectorTree, discriminatorTree, msg );
          
    if (tc.isEntryEnabled()) SibTr.exit(tc, "evaluateMessage", new Boolean(ret));
    return ret;             
  }