if we mine a null round, wait until end of current round before attempting to continue

This commit is contained in:
whyrusleeping 2019-10-09 18:18:33 +09:00
parent a6f6674468
commit 8a374232fb

View File

@ -145,6 +145,8 @@ func (m *Miner) mine(ctx context.Context) {
return
default:
}
// Sleep a small amount in order to wait for other blocks to arrive
if err := m.waitFunc(ctx); err != nil {
log.Error(err)
return
@ -173,6 +175,9 @@ func (m *Miner) mine(ctx context.Context) {
if err := m.api.ChainSubmitBlock(ctx, b); err != nil {
log.Errorf("failed to submit newly mined block: %s", err)
}
} else {
nextRound := time.Unix(int64(base.ts.MinTimestamp()+uint64(build.BlockDelay*len(base.tickets))), 0)
time.Sleep(time.Until(nextRound))
}
}
}