lpwinning: select lowest epoch task id for mining task
This commit is contained in:
parent
339e062975
commit
30cf227ef5
@ -398,7 +398,23 @@ func (t *WinPostTask) CanAccept(ids []harmonytask.TaskID, engine *harmonytask.Ta
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
return &ids[0], nil
|
||||
// select lowest epoch
|
||||
var lowestEpoch abi.ChainEpoch
|
||||
var lowestEpochID = ids[0]
|
||||
for _, id := range ids {
|
||||
var epoch uint64
|
||||
err := t.db.QueryRow(context.Background(), `SELECT epoch FROM mining_tasks WHERE task_id = $1`, id).Scan(&epoch)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if lowestEpoch == 0 || abi.ChainEpoch(epoch) < lowestEpoch {
|
||||
lowestEpoch = abi.ChainEpoch(epoch)
|
||||
lowestEpochID = id
|
||||
}
|
||||
}
|
||||
|
||||
return &lowestEpochID, nil
|
||||
}
|
||||
|
||||
func (t *WinPostTask) TypeDetails() harmonytask.TaskTypeDetails {
|
||||
|
Loading…
Reference in New Issue
Block a user