code: func (n *Node) registerNode(node *api.RaftMember) error {
  	if n.cluster.IsIDRemoved(node.RaftID) {
  		return nil
  	}
  
  	member := &membership.Member{}
  
  	existingMember := n.cluster.GetMember(node.RaftID)
  	if existingMember != nil {
  		// Member already exists
  
  		// If the address is different from what we thought it was,
  		// update it. This can happen if we just joined a cluster
  		// and are adding ourself now with the remotely-reachable
  		// address.
  		if existingMember.Addr != node.Addr {
  			if node.RaftID != n.Config.ID {
  				if err := n.transport.UpdatePeer(node.RaftID, node.Addr); err != nil {
  					return err
  				}
  			}
  			member.RaftMember = node
  			n.cluster.AddMember(member)
  		}
  
  		return nil
  	}
  
  	// Avoid opening a connection to the local node
  	if node.RaftID != n.Config.ID {
  		if err := n.transport.AddPeer(node.RaftID, node.Addr); err != nil {
  			return err
  		}
  	}
  
  	member.RaftMember = node
  	err := n.cluster.AddMember(member)
  	if err != nil {
  		if rerr := n.transport.RemovePeer(node.RaftID); rerr != nil {
  			return errors.Wrapf(rerr, "failed to remove peer after error %v", err)
  		}
  		return err
  	}
  
  	return nil
  }
docs: // registerNode registers a new node on the cluster memberlist