Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions task/processor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/ethereum/go-ethereum/rpc"
"github.com/pkg/errors"

"github.com/iotexproject/w3bstream/metrics"
"github.com/iotexproject/w3bstream/project"
"github.com/iotexproject/w3bstream/smartcontracts/go/router"
"github.com/iotexproject/w3bstream/task"
Expand Down Expand Up @@ -47,21 +48,29 @@ type processor struct {
func (r *processor) process(ts []*task.Task, c *project.Config, pid string) error {
slog.Info("process tasks", "project_id", pid, "vm_type", c.VMTypeID, "tasks_len", len(ts))
startTime := time.Now()
// proof, err := r.handle(ts, c)
// if err != nil {
// metrics.FailedTaskNumMtc.WithLabelValues(pid).Inc()
// slog.Error("failed to handle task", "error", err)
// return err
// }

var proof []byte
var err error
if pid != "9" {
proof, err = r.handle(ts, c)
if err != nil {
metrics.FailedTaskNumMtc.WithLabelValues(pid).Inc()
slog.Error("failed to handle task", "error", err)
return err
}
}
processTime := time.Since(startTime)
slog.Info("process task success", "project_id", pid, "process_time", processTime)
//metrics.TaskDurationMtc.WithLabelValues(pid, t.ProjectVersion, t.ID.String()).Set(processTime.Seconds())

pubkey, err := crypto.UnmarshalPubkey(ts[0].DevicePubKey)
if err != nil {
return errors.Wrap(err, "failed to unmarshal device public key")
if pid == "9" {
pubkey, err := crypto.UnmarshalPubkey(ts[0].DevicePubKey)
if err != nil {
return errors.Wrap(err, "failed to unmarshal device public key")
}
deviceAddr := crypto.PubkeyToAddress(*pubkey)
proof = common.LeftPadBytes(deviceAddr.Bytes(), 32)
}
deviceAddr := crypto.PubkeyToAddress(*pubkey)

tids := [][32]byte{}
for _, t := range ts {
Expand All @@ -81,7 +90,7 @@ func (r *processor) process(ts []*task.Task, c *project.Config, pid string) erro
r.account,
pidInt,
tids,
common.LeftPadBytes(deviceAddr.Bytes(), 32),
proof,
)
if err != nil {
if jsonErr, ok := err.(rpc.DataError); ok {
Expand Down