code: func (w *wallet) heartbeat() {
  	w.log.Debug("USB wallet health-check started")
  	defer w.log.Debug("USB wallet health-check stopped")
  
  	// Execute heartbeat checks until termination or error
  	var (
  		errc chan error
  		err  error
  	)
  	for errc == nil && err == nil {
  		// Wait until termination is requested or the heartbeat cycle arrives
  		select {
  		case errc = <-w.healthQuit:
  			// Termination requested
  			continue
  		case <-time.After(heartbeatCycle):
  			// Heartbeat time
  		}
  		// Execute a tiny data exchange to see responsiveness
  		w.stateLock.RLock()
  		if w.device == nil {
  			// Terminated while waiting for the lock
  			w.stateLock.RUnlock()
  			continue
  		}
  		<-w.commsLock // Don't lock state while resolving version
  		err = w.driver.Heartbeat()
  		w.commsLock <- struct{}{}
  		w.stateLock.RUnlock()
  
  		if err != nil {
  			w.stateLock.Lock() // Lock state to tear the wallet down
  			w.close()
  			w.stateLock.Unlock()
  		}
  		// Ignore non hardware related errors
  		err = nil
  	}
  	// In case of error, wait for termination
  	if err != nil {
  		w.log.Debug("USB wallet health-check failed", "err", err)
  		errc = <-w.healthQuit
  	}
  	errc <- err
  }
docs: // heartbeat is a health check loop for the USB wallets to periodically verify
  // whether they are still present or if they malfunctioned.