change minerStop to minerLoop

This commit is contained in:
zgfzgf 2020-09-23 20:24:19 +08:00
parent 001ba17d37
commit a4ade158f4

View File

@ -149,9 +149,8 @@ func (m *Miner) mine(ctx context.Context) {
defer span.End()
var lastBase MiningBase
minerLoop:
for {
minerStop:
select {
case <-m.stop:
stopping := m.stopping
@ -172,7 +171,7 @@ func (m *Miner) mine(ctx context.Context) {
if err != nil {
log.Errorf("failed to get best mining candidate: %s", err)
if !m.niceSleep(time.Second * 5) {
goto minerStop
goto minerLoop
}
continue
}
@ -204,7 +203,7 @@ func (m *Miner) mine(ctx context.Context) {
if err != nil {
log.Errorf("failed getting beacon entry: %s", err)
if !m.niceSleep(time.Second) {
goto minerStop
goto minerLoop
}
continue
}
@ -215,7 +214,7 @@ func (m *Miner) mine(ctx context.Context) {
if base.TipSet.Equals(lastBase.TipSet) && lastBase.NullRounds == base.NullRounds {
log.Warnf("BestMiningCandidate from the previous round: %s (nulls:%d)", lastBase.TipSet.Cids(), lastBase.NullRounds)
if !m.niceSleep(time.Duration(build.BlockDelaySecs) * time.Second) {
goto minerStop
goto minerLoop
}
continue
}
@ -226,7 +225,7 @@ func (m *Miner) mine(ctx context.Context) {
if err != nil {
log.Errorf("mining block failed: %+v", err)
if !m.niceSleep(time.Second) {
goto minerStop
goto minerLoop
}
onDone(false, 0, err)
continue