def msg_clientrequest(self, conn, msg):
        """called holding self.lock
        handles clientrequest message received according to replica's state
        - if not leader: reject
        - if leader: add connection to client connections and handle request"""
        if len(self.replicas) == 0:
            if self.debug: self.logger.write("State", "Adding SELF")
            # Agree on adding self and the first replica:
            self.become_leader()
            # Add self
            self.replicas[self.me] = 0
            addcommand = self.create_add_command(self.me)
            self.pick_commandnumber_add_to_pending(addcommand)
            for i in range(WINDOW+3):
                noopcommand = self.create_noop_command()
                self.pick_commandnumber_add_to_pending(noopcommand)
            self.issue_pending_commands()
            return
        if not self.stateuptodate:
            return
        if self.isleader:
            # if leader, handle the clientrequest
            if self.token and msg.token != self.token:
                if self.debug: self.logger.write("Error", "Security Token mismatch.")
                self.send_reject_to_client(conn, msg.command.clientcommandnumber)
            else:
                if self.debug: self.logger.write("State", "I'm the leader, handling the request.")
                self.handle_client_command(msg.command, msg.sendcount,
                                           prepare=self.leader_initializing)
        else:
            leaderalive, leader = self.leader_is_alive()
            if leaderalive and leader != self.me:
                if self.debug: self.logger.write("State", "Not Leader: Rejecting CLIENTREQUEST")
                self.send_reject_to_client(conn, msg.command.clientcommandnumber)
            elif leader == self.me:
                # check if should become leader
                self.become_leader()
                if self.token and msg.token != self.token:
                    if self.debug: self.logger.write("Error", "Security Token mismatch.")
                    self.send_reject_to_client(conn, msg.command.clientcommandnumber)
                else:
                    self.handle_client_command(msg.command, msg.sendcount,
                                               prepare=self.leader_initializing)
            elif not leaderalive and self.find_leader() == self.me:
                # check if should become leader
                self.become_leader()
                if leader not in self.nodesbeingdeleted and self.replicas in leader:
                    # if leader is not already (being) deleted
                    # take old leader out of the configuration
                    if self.debug: self.logger.write("State",
                                                     "Taking old leader out of the configuration.")
                    self.nodesbeingdeleted.add(leader)
                    delcommand = self.create_delete_command(leader)
                    self.pick_commandnumber_add_to_pending(delcommand)
                    for i in range(WINDOW):
                        noopcommand = self.create_noop_command()
                        self.pick_commandnumber_add_to_pending(noopcommand)
                    self.issue_pending_commands()
                # Check token and answer to client
                if self.token and msg.token != self.token:
                    if self.debug: self.logger.write("Error", "Security Token mismatch.")
                    self.send_reject_to_client(conn, msg.command.clientcommandnumber)
                else:
                    self.handle_client_command(msg.command, msg.sendcount,
                                               prepare=self.leader_initializing)
dataset/ETHPy150Open denizalti/concoord/concoord/replica.py/Replica.msg_clientrequest/swapped operands of `in`