code: func (state *gbtWorkState) templateUpdateChan(prevHash *chainhash.Hash, lastGenerated int64) chan struct{} {
  	// Either get the current list of channels waiting for updates about
  	// changes to block template for the previous hash or create a new one.
  	channels, ok := state.notifyMap[*prevHash]
  	if !ok {
  		m := make(map[int64]chan struct{})
  		state.notifyMap[*prevHash] = m
  		channels = m
  	}
  
  	// Get the current channel associated with the time the block template
  	// was last generated or create a new one.
  	c, ok := channels[lastGenerated]
  	if !ok {
  		c = make(chan struct{})
  		channels[lastGenerated] = c
  	}
  
  	return c
  }
docs: // templateUpdateChan returns a channel that will be closed once the block
  // template associated with the passed previous hash and last generated time
  // is stale.  The function will return existing channels for duplicate
  // parameters which allows multiple clients to wait for the same block template
  // without requiring a different channel for each client.
  //
  // This function MUST be called with the state locked.