// loop monitors mining events on the work and quit channels, updating the internal
// state of the remote miner until a termination is requested.
//
// Note, the reason the work and quit channels are passed as parameters is because
// RemoteAgent.Start() constantly recreates these channels, so the loop code cannot
// assume data stability in these member fields.
loop monitors mining events on the work and quit channels, updating the internal
state of the remote miner until a termination is requested.

Note, the reason the work and quit channels are passed as parameters is because
RemoteAgent.Start() constantly recreates these channels, so the loop code cannot
assume data stability in these member fields.
// loop monitors mining events on the work and quit channels updating the internal // state of the remote miner until a termination is requested . // // Note the reason the work and quit channels are passed as parameters is because // RemoteAgent . Start () constantly recreates these channels so the loop code cannot // assume data stability in these member fields .
func (a *RemoteAgent) loop(workCh chan *Work, quitCh chan struct{}) {
	ticker := time.NewTicker(5 * time.Second)
	defer ticker.Stop()
	for {
		select {
		case <-quitCh:
			return
		case work := <-workCh:
			a.mu.Lock()
			a.currentWork = work
			a.mu.Unlock()
		case <-ticker.C:
			a.hashrateMu.Lock()
			for id, hashrate := range a.hashrate {
				if time.Since(hashrate.ping) > 10*time.Second {
					delete(a.hashrate, id)
				}
			}
			a.hashrateMu.Unlock()
		}
	}
}
func ( a * RemoteAgent ) loop ( workCh chan * Work , quitCh chan struct { } ) { ticker := time . NewTicker ( 5 * time . Second ) defer ticker . Stop ( ) for { select { case <- quitCh : return case work := <- workCh : a . mu . Lock ( ) a . currentWork = work a . mu . Unlock ( ) case <- ticker . C : a . hashrateMu . Lock ( ) for id , hashrate := range a . hashrate { if time . Since ( hashrate . ping ) > 10 * time . Second { delete ( a . hashrate , id ) } } a . hashrateMu . Unlock ( ) } } }
loop monitors mining events on the work and quit channels, updating the internal
state of the remote miner until a termination is requested.
loop monitors mining events on the work and quit channels updating the internal state of the remote miner until a termination is requested .
// cleanup /*
				a.mu.Lock()
				for hash, work := range a.work {
					if time.Since(work.createdAt) > 7*(12*time.Second) {
						delete(a.work, hash)
					}
				}
				a.mu.Unlock()
			*/ //YYYYYYYYYYYYYYYYYYYYYYYY 测试注释