code: func (h *haManager) setState(s seesaw.HAState) {
  	state := h.state()
  
  	if state == seesaw.HADisabled && s != seesaw.HAUnknown {
  		log.Warningf("Invalid HA state transition %v -> %v", state, s)
  		return
  	}
  
  	if state != s {
  		log.Infof("HA state transition %v -> %v starting", state, s)
  		if s == seesaw.HAMaster {
  			h.engine.becomeMaster()
  		} else if state == seesaw.HAMaster || s == seesaw.HABackup {
  			h.engine.becomeBackup()
  		}
  		log.Infof("HA state transition %v -> %v complete", state, s)
  	}
  
  	now := time.Now()
  
  	h.statusLock.Lock()
  	h.status.State = s
  	h.status.Since = now
  	h.status.LastUpdate = now
  	h.statusLock.Unlock()
  }
docs: // setState sets the HAState of the engine and dispatches events when the state
  // changes.