code: func (s *Store) ensureCheckCASTxn(tx *memdb.Txn, idx uint64, hc *structs.HealthCheck) (bool, error) {
  	// Retrieve the existing entry.
  	_, existing, err := s.getNodeCheckTxn(tx, hc.Node, hc.CheckID)
  	if err != nil {
  		return false, fmt.Errorf("failed health check lookup: %s", err)
  	}
  
  	// Check if the we should do the set. A ModifyIndex of 0 means that
  	// we are doing a set-if-not-exists.
  	if hc.ModifyIndex == 0 && existing != nil {
  		return false, nil
  	}
  	if hc.ModifyIndex != 0 && existing == nil {
  		return false, nil
  	}
  	if existing != nil && hc.ModifyIndex != 0 && hc.ModifyIndex != existing.ModifyIndex {
  		return false, nil
  	}
  
  	// Perform the update.
  	if err := s.ensureCheckTxn(tx, idx, hc); err != nil {
  		return false, err
  	}
  
  	return true, nil
  }
docs: // ensureCheckCASTxn updates a check only if the existing index matches the given index.
  // Returns a bool indicating if a write happened and any error.