code: func (s *Store) CASetProviderState(idx uint64, state *structs.CAConsulProviderState) (bool, error) {
  	tx := s.db.Txn(true)
  	defer tx.Abort()
  
  	// Check for an existing config
  	existing, err := tx.First(caBuiltinProviderTableName, "id", state.ID)
  	if err != nil {
  		return false, fmt.Errorf("failed built-in CA state lookup: %s", err)
  	}
  
  	// Set the indexes.
  	if existing != nil {
  		state.CreateIndex = existing.(*structs.CAConsulProviderState).CreateIndex
  	} else {
  		state.CreateIndex = idx
  	}
  	state.ModifyIndex = idx
  
  	if err := tx.Insert(caBuiltinProviderTableName, state); err != nil {
  		return false, fmt.Errorf("failed updating built-in CA state: %s", err)
  	}
  
  	// Update the index
  	if err := tx.Insert("index", &IndexEntry{caBuiltinProviderTableName, idx}); err != nil {
  		return false, fmt.Errorf("failed updating index: %s", err)
  	}
  
  	tx.Commit()
  
  	return true, nil
  }
docs: // CASetProviderState is used to set the current built-in CA provider state.