Unrevert #2832 with fixed code
This commit is contained in:
parent
3bac504fc3
commit
c62859e38b
@ -148,6 +148,11 @@ func (m *Miner) mine(ctx context.Context) {
|
|||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var base *MiningBase
|
||||||
|
var onDone func(bool, error)
|
||||||
|
var injectNulls abi.ChainEpoch
|
||||||
|
|
||||||
|
for {
|
||||||
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)
|
||||||
@ -155,19 +160,38 @@ func (m *Miner) mine(ctx context.Context) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if base != nil && base.TipSet.Height() == prebase.TipSet.Height() && base.NullRounds == prebase.NullRounds {
|
||||||
|
base = prebase
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if base != nil {
|
||||||
|
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
|
// Wait until propagation delay period after block we plan to mine on
|
||||||
onDone, injectNulls, err := m.waitFunc(ctx, prebase.TipSet.MinTimestamp())
|
onDone, injectNulls, err = m.waitFunc(ctx, prebase.TipSet.MinTimestamp())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
base, err := m.GetBestMiningCandidate(ctx)
|
// 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 {
|
if err != nil {
|
||||||
log.Errorf("failed to get best mining candidate: %s", err)
|
log.Errorf("failed getting beacon entry: %s", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
base = prebase
|
||||||
|
}
|
||||||
|
|
||||||
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)
|
m.niceSleep(time.Duration(build.BlockDelaySecs) * time.Second)
|
||||||
|
Loading…
Reference in New Issue
Block a user