don't sleep if no block mined

This commit is contained in:
whyrusleeping 2019-10-09 18:11:41 +09:00
parent 719f20d091
commit a6f6674468

View File

@ -164,12 +164,12 @@ func (m *Miner) mine(ctx context.Context) {
continue
}
btime := time.Unix(int64(b.Header.Timestamp), 0)
if time.Now().Before(btime) {
time.Sleep(time.Until(btime))
}
if b != nil {
btime := time.Unix(int64(b.Header.Timestamp), 0)
if time.Now().Before(btime) {
time.Sleep(time.Until(btime))
}
if err := m.api.ChainSubmitBlock(ctx, b); err != nil {
log.Errorf("failed to submit newly mined block: %s", err)
}