code: func (state *gbtWorkState) notifyLongPollers(latestHash *chainhash.Hash, lastGenerated time.Time) {
  	// Notify anything that is waiting for a block template update from a
  	// hash which is not the hash of the tip of the best chain since their
  	// work is now invalid.
  	for hash, channels := range state.notifyMap {
  		if !hash.IsEqual(latestHash) {
  			for _, c := range channels {
  				close(c)
  			}
  			delete(state.notifyMap, hash)
  		}
  	}
  
  	// Return now if the provided last generated timestamp has not been
  	// initialized.
  	if lastGenerated.IsZero() {
  		return
  	}
  
  	// Return now if there is nothing registered for updates to the current
  	// best block hash.
  	channels, ok := state.notifyMap[*latestHash]
  	if !ok {
  		return
  	}
  
  	// Notify anything that is waiting for a block template update from a
  	// block template generated before the most recently generated block
  	// template.
  	lastGeneratedUnix := lastGenerated.Unix()
  	for lastGen, c := range channels {
  		if lastGen < lastGeneratedUnix {
  			close(c)
  			delete(channels, lastGen)
  		}
  	}
  
  	// Remove the entry altogether if there are no more registered
  	// channels.
  	if len(channels) == 0 {
  		delete(state.notifyMap, *latestHash)
  	}
  }
docs: // notifyLongPollers notifies any channels that have been registered to be
  // notified when block templates are stale.
  //
  // This function MUST be called with the state locked.