2020-03-23 11:40:02 +00:00
|
|
|
package sealtasks
|
|
|
|
|
|
|
|
type TaskType string
|
|
|
|
|
|
|
|
const (
|
|
|
|
TTAddPiece TaskType = "seal/v0/addpiece"
|
|
|
|
TTPreCommit1 TaskType = "seal/v0/precommit/1"
|
|
|
|
TTPreCommit2 TaskType = "seal/v0/precommit/2"
|
|
|
|
TTCommit1 TaskType = "seal/v0/commit/1" // NOTE: We use this to transfer the sector into miner-local storage for now; Don't use on workers!
|
|
|
|
TTCommit2 TaskType = "seal/v0/commit/2"
|
|
|
|
|
|
|
|
TTFinalize TaskType = "seal/v0/finalize"
|
2020-04-27 12:55:37 +00:00
|
|
|
|
2021-05-20 16:25:49 +00:00
|
|
|
TTFetch TaskType = "seal/v0/fetch"
|
|
|
|
TTUnseal TaskType = "seal/v0/unseal"
|
2021-11-10 18:53:00 +00:00
|
|
|
|
|
|
|
TTReplicaUpdate TaskType = "seal/v0/replicaupdate"
|
|
|
|
TTProveReplicaUpdate1 TaskType = "seal/v0/provereplicaupdate/1"
|
|
|
|
TTProveReplicaUpdate2 TaskType = "seal/v0/provereplicaupdate/2"
|
2021-12-01 19:01:55 +00:00
|
|
|
TTRegenSectorKey TaskType = "seal/v0/regensectorkey"
|
2021-07-27 03:15:53 +00:00
|
|
|
|
|
|
|
TTGenerateWindowPoSt TaskType = "post/v0/windowproof"
|
|
|
|
TTGenerateWinningPoSt TaskType = "post/v0/winningproof"
|
2020-03-23 11:40:02 +00:00
|
|
|
)
|
2020-05-07 23:38:05 +00:00
|
|
|
|
|
|
|
var order = map[TaskType]int{
|
2021-12-01 19:01:55 +00:00
|
|
|
TTRegenSectorKey: 10, // least priority
|
|
|
|
TTAddPiece: 9,
|
2021-11-10 18:53:00 +00:00
|
|
|
TTReplicaUpdate: 8,
|
|
|
|
TTProveReplicaUpdate2: 7,
|
|
|
|
TTProveReplicaUpdate1: 6,
|
|
|
|
TTPreCommit1: 5,
|
|
|
|
TTPreCommit2: 4,
|
|
|
|
TTCommit2: 3,
|
|
|
|
TTCommit1: 2,
|
|
|
|
TTUnseal: 1,
|
|
|
|
TTFetch: -1,
|
|
|
|
TTFinalize: -2, // most priority
|
2021-07-27 03:15:53 +00:00
|
|
|
|
|
|
|
TTGenerateWindowPoSt: -3,
|
|
|
|
TTGenerateWinningPoSt: -4,
|
2020-05-07 23:38:05 +00:00
|
|
|
}
|
|
|
|
|
2020-07-21 18:01:25 +00:00
|
|
|
var shortNames = map[TaskType]string{
|
2020-12-09 11:22:21 +00:00
|
|
|
TTAddPiece: "AP",
|
2020-07-21 18:01:25 +00:00
|
|
|
|
|
|
|
TTPreCommit1: "PC1",
|
|
|
|
TTPreCommit2: "PC2",
|
2020-12-09 11:22:21 +00:00
|
|
|
TTCommit1: "C1",
|
|
|
|
TTCommit2: "C2",
|
2020-07-21 18:01:25 +00:00
|
|
|
|
|
|
|
TTFinalize: "FIN",
|
|
|
|
|
2021-05-20 16:25:49 +00:00
|
|
|
TTFetch: "GET",
|
|
|
|
TTUnseal: "UNS",
|
2021-11-10 18:53:00 +00:00
|
|
|
|
|
|
|
TTReplicaUpdate: "RU",
|
|
|
|
TTProveReplicaUpdate1: "PR1",
|
|
|
|
TTProveReplicaUpdate2: "PR2",
|
2021-12-01 19:01:55 +00:00
|
|
|
TTRegenSectorKey: "GSK",
|
2021-07-27 03:15:53 +00:00
|
|
|
|
|
|
|
TTGenerateWindowPoSt: "WDP",
|
|
|
|
TTGenerateWinningPoSt: "WNP",
|
2020-07-21 18:01:25 +00:00
|
|
|
}
|
|
|
|
|
2020-08-27 21:28:52 +00:00
|
|
|
func (a TaskType) MuchLess(b TaskType) (bool, bool) {
|
|
|
|
oa, ob := order[a], order[b]
|
|
|
|
oneNegative := oa^ob < 0
|
|
|
|
return oneNegative, oa < ob
|
|
|
|
}
|
|
|
|
|
2020-05-07 23:38:05 +00:00
|
|
|
func (a TaskType) Less(b TaskType) bool {
|
|
|
|
return order[a] < order[b]
|
|
|
|
}
|
2020-07-21 18:01:25 +00:00
|
|
|
|
|
|
|
func (a TaskType) Short() string {
|
|
|
|
n, ok := shortNames[a]
|
|
|
|
if !ok {
|
|
|
|
return "UNK"
|
|
|
|
}
|
|
|
|
|
|
|
|
return n
|
|
|
|
}
|