fix ticket expired

This commit is contained in:
yaohcn 2021-05-20 18:36:00 +08:00
parent 6f55031faa
commit e21d4d7a7e

View File

@ -99,8 +99,8 @@ func (m *Sealing) padSector(ctx context.Context, sectorID storage.SectorRef, exi
return out, nil return out, nil
} }
func checkTicketExpired(sector SectorInfo, epoch abi.ChainEpoch) bool { func checkTicketExpired(ticket, head abi.ChainEpoch) bool {
return epoch-sector.TicketEpoch > MaxTicketAge // TODO: allow configuring expected seal durations return head-ticket > MaxTicketAge // TODO: allow configuring expected seal durations
} }
func (m *Sealing) getTicket(ctx statemachine.Context, sector SectorInfo) (abi.SealRandomness, abi.ChainEpoch, error) { func (m *Sealing) getTicket(ctx statemachine.Context, sector SectorInfo) (abi.SealRandomness, abi.ChainEpoch, error) {
@ -124,7 +124,7 @@ func (m *Sealing) getTicket(ctx statemachine.Context, sector SectorInfo) (abi.Se
if pci != nil { if pci != nil {
ticketEpoch = pci.Info.SealRandEpoch ticketEpoch = pci.Info.SealRandEpoch
if checkTicketExpired(sector, ticketEpoch) { if checkTicketExpired(ticketEpoch, epoch) {
return nil, 0, xerrors.Errorf("ticket expired for precommitted sector") return nil, 0, xerrors.Errorf("ticket expired for precommitted sector")
} }
} }
@ -186,7 +186,7 @@ func (m *Sealing) handlePreCommit1(ctx statemachine.Context, sector SectorInfo)
return nil return nil
} }
if checkTicketExpired(sector, height) { if checkTicketExpired(sector.TicketEpoch, height) {
return ctx.Send(SectorOldTicket{}) // go get new ticket return ctx.Send(SectorOldTicket{}) // go get new ticket
} }