Revert #2832 fully

This commit is contained in:
Łukasz Magiera 2020-08-07 17:51:03 +02:00
parent 9b28be14cd
commit c8cf8f3ee1

View File

@ -148,47 +148,24 @@ func (m *Miner) mine(ctx context.Context) {
default: default:
} }
var base *MiningBase prebase, err := m.GetBestMiningCandidate(ctx)
var onDone func(bool, error) if err != nil {
var injectNulls abi.ChainEpoch log.Errorf("failed to get best mining candidate: %s", err)
m.niceSleep(time.Second * 5)
continue
}
for { // Wait until propagation delay period after block we plan to mine on
prebase, err := m.GetBestMiningCandidate(ctx) onDone, injectNulls, err := m.waitFunc(ctx, prebase.TipSet.MinTimestamp())
if err != nil { if err != nil {
log.Errorf("failed to get best mining candidate: %s", err) log.Error(err)
m.niceSleep(time.Second * 5) continue
continue }
}
if base != nil && base.TipSet.Height() == prebase.TipSet.Height() && base.NullRounds == prebase.NullRounds { base, err := m.GetBestMiningCandidate(ctx)
break if err != nil {
} log.Errorf("failed to get best mining candidate: %s", err)
if base != nil { continue
onDone(false, nil)
}
// TODO: need to change the orchestration here. the problem is that
// we are waiting *after* we enter this loop and selecta mining
// candidate, which is almost certain to change in multiminer
// tests. Instead, we should block before entering the loop, so
// that when the test 'MineOne' function is triggered, we pull our
// best mining candidate at that time.
// Wait until propagation delay period after block we plan to mine on
onDone, injectNulls, err = m.waitFunc(ctx, prebase.TipSet.MinTimestamp())
if err != nil {
log.Error(err)
continue
}
/*// just wait for the beacon entry to become available before we select our final mining base
_, err = m.api.BeaconGetEntry(ctx, prebase.TipSet.Height()+prebase.NullRounds+1)
if err != nil {
log.Errorf("failed getting beacon entry: %s", err)
continue
}*/
base = prebase
} }
if base.TipSet.Equals(lastBase.TipSet) && lastBase.NullRounds == base.NullRounds { if base.TipSet.Equals(lastBase.TipSet) && lastBase.NullRounds == base.NullRounds {