break out of mining loop when stop is called during niceSleep
This commit is contained in:
parent
0c1c19c6ef
commit
808051d34e
@ -139,6 +139,7 @@ func (m *Miner) niceSleep(d time.Duration) bool {
|
|||||||
case <-build.Clock.After(d):
|
case <-build.Clock.After(d):
|
||||||
return true
|
return true
|
||||||
case <-m.stop:
|
case <-m.stop:
|
||||||
|
log.Infow("recieved interrupt while trying to sleep in mining cycle")
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -169,7 +170,9 @@ func (m *Miner) mine(ctx context.Context) {
|
|||||||
prebase, err := m.GetBestMiningCandidate(ctx)
|
prebase, err := m.GetBestMiningCandidate(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("failed to get best mining candidate: %s", err)
|
log.Errorf("failed to get best mining candidate: %s", err)
|
||||||
m.niceSleep(time.Second * 5)
|
if !m.niceSleep(time.Second * 5) {
|
||||||
|
break
|
||||||
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,7 +202,9 @@ func (m *Miner) mine(ctx context.Context) {
|
|||||||
_, err = m.api.BeaconGetEntry(ctx, prebase.TipSet.Height()+prebase.NullRounds+1)
|
_, err = m.api.BeaconGetEntry(ctx, prebase.TipSet.Height()+prebase.NullRounds+1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("failed getting beacon entry: %s", err)
|
log.Errorf("failed getting beacon entry: %s", err)
|
||||||
m.niceSleep(time.Second)
|
if !m.niceSleep(time.Second) {
|
||||||
|
break
|
||||||
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,7 +213,9 @@ func (m *Miner) mine(ctx context.Context) {
|
|||||||
|
|
||||||
if base.TipSet.Equals(lastBase.TipSet) && lastBase.NullRounds == base.NullRounds {
|
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)
|
log.Warnf("BestMiningCandidate from the previous round: %s (nulls:%d)", lastBase.TipSet.Cids(), lastBase.NullRounds)
|
||||||
m.niceSleep(time.Duration(build.BlockDelaySecs) * time.Second)
|
if !m.niceSleep(time.Duration(build.BlockDelaySecs) * time.Second) {
|
||||||
|
break
|
||||||
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,7 +224,9 @@ func (m *Miner) mine(ctx context.Context) {
|
|||||||
b, err := m.mineOne(ctx, base)
|
b, err := m.mineOne(ctx, base)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("mining block failed: %+v", err)
|
log.Errorf("mining block failed: %+v", err)
|
||||||
m.niceSleep(time.Second)
|
if !m.niceSleep(time.Second) {
|
||||||
|
break
|
||||||
|
}
|
||||||
onDone(false, 0, err)
|
onDone(false, 0, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user