Share ProvingPeriodEnd math
This commit is contained in:
parent
636c978054
commit
e0632a93ab
@ -295,6 +295,14 @@ type SubmitPoStParams struct {
|
||||
// TODO: once the spec changes finish, we have more work to do here...
|
||||
}
|
||||
|
||||
func ProvingPeriodEnd(setPeriodEnd, height uint64) (uint64, uint64) {
|
||||
offset := setPeriodEnd % build.ProvingPeriodDuration
|
||||
period := ((height - offset - 1) / build.ProvingPeriodDuration) + 1
|
||||
end := (period * build.ProvingPeriodDuration) + offset
|
||||
|
||||
return end, period
|
||||
}
|
||||
|
||||
// TODO: this is a dummy method that allows us to plumb in other parts of the
|
||||
// system for now.
|
||||
func (sma StorageMinerActor) SubmitPoSt(act *types.Actor, vmctx types.VMContext, params *SubmitPoStParams) ([]byte, ActorError) {
|
||||
@ -312,9 +320,7 @@ func (sma StorageMinerActor) SubmitPoSt(act *types.Actor, vmctx types.VMContext,
|
||||
return nil, aerrors.New(1, "not authorized to submit post for miner")
|
||||
}
|
||||
|
||||
provingPeriodOffset := self.ProvingPeriodEnd % build.ProvingPeriodDuration
|
||||
provingPeriod := (vmctx.BlockHeight()-provingPeriodOffset-1)/build.ProvingPeriodDuration + 1
|
||||
currentProvingPeriodEnd := provingPeriod*build.ProvingPeriodDuration + provingPeriodOffset
|
||||
currentProvingPeriodEnd, _ := ProvingPeriodEnd(self.ProvingPeriodEnd, vmctx.BlockHeight())
|
||||
|
||||
feesRequired := types.NewInt(0)
|
||||
|
||||
|
@ -37,9 +37,7 @@ func (m *Miner) beginPosting(ctx context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
provingPeriodOffset := ppe % build.ProvingPeriodDuration
|
||||
provingPeriod := (ts.Height()-provingPeriodOffset)/build.ProvingPeriodDuration + 1
|
||||
m.schedPost = provingPeriod*build.ProvingPeriodDuration + provingPeriodOffset
|
||||
m.schedPost, _ = actors.ProvingPeriodEnd(ppe, ts.Height())
|
||||
|
||||
m.schedLk.Unlock()
|
||||
|
||||
@ -64,9 +62,7 @@ func (m *Miner) scheduleNextPost(ppe uint64) {
|
||||
return
|
||||
}
|
||||
|
||||
provingPeriodOffset := ppe % build.ProvingPeriodDuration
|
||||
provingPeriod := (ts.Height()-provingPeriodOffset-1)/build.ProvingPeriodDuration + 1
|
||||
headPPE := provingPeriod*build.ProvingPeriodDuration + provingPeriodOffset
|
||||
headPPE, provingPeriod := actors.ProvingPeriodEnd(ppe, ts.Height())
|
||||
if headPPE > ppe {
|
||||
log.Warn("PoSt computation running behind chain")
|
||||
ppe = headPPE
|
||||
|
Loading…
Reference in New Issue
Block a user