Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

break error #3953

Merged
merged 2 commits into from
Sep 24, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions miner/miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ func (m *Miner) mine(ctx context.Context) {
var lastBase MiningBase

for {
minerStop:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could change this to

Suggested change
for {
minerStop:
minerLoop:
for {

And then use continue minerLoop instead of goto below

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now it's changed

select {
case <-m.stop:
stopping := m.stopping
Expand All @@ -171,7 +172,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) {
break
goto minerStop
}
continue
}
Expand Down Expand Up @@ -203,7 +204,7 @@ func (m *Miner) mine(ctx context.Context) {
if err != nil {
log.Errorf("failed getting beacon entry: %s", err)
if !m.niceSleep(time.Second) {
break
goto minerStop
}
continue
}
Expand All @@ -214,7 +215,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) {
break
goto minerStop
}
continue
}
Expand All @@ -225,7 +226,7 @@ func (m *Miner) mine(ctx context.Context) {
if err != nil {
log.Errorf("mining block failed: %+v", err)
if !m.niceSleep(time.Second) {
break
goto minerStop
}
onDone(false, 0, err)
continue
Expand Down