Skip to content

Commit

Permalink
pref: reduce the amount of rpc data transfer
Browse files Browse the repository at this point in the history
  • Loading branch information
0x5459 committed Jul 28, 2023
1 parent 97b2b78 commit 726eacc
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion damocles-manager/core/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,5 +158,5 @@ type WorkerWdPoStAPI interface {
WdPoStFinishJob(ctx context.Context, jobID string, output *stage.WindowPoStOutput, errorReason string) (Meta, error)
WdPoStResetJob(ctx context.Context, jobID string) (Meta, error)
WdPoStRemoveJob(ctx context.Context, jobID string) (Meta, error)
WdPoStAllJobs(ctx context.Context) ([]*WdPoStJob, error)
WdPoStAllJobs(ctx context.Context) ([]*WdPoStJobBrief, error)
}
11 changes: 11 additions & 0 deletions damocles-manager/core/types_wdpost.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package core

import (
"context"
"encoding/json"
"time"

"github.com/filecoin-project/go-state-types/abi"
Expand Down Expand Up @@ -80,6 +81,16 @@ func (t *WdPoStJob) DisplayState() string {
return t.State
}

type WdPoStJobBrief struct {
WdPoStJob
}

func (j *WdPoStJobBrief) MarshalJSON() ([]byte, error) {
j.Input = WdPoStInput{}
j.Output = &stage.WindowPoStOutput{}
return json.Marshal(j)
}

type WdPoStAllocatedJob struct {
ID string `json:"Id"`
Input WdPoStInput
Expand Down
2 changes: 1 addition & 1 deletion damocles-manager/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ require (
github.com/jbenet/go-random v0.0.0-20190219211222-123a90aedc0c
github.com/libp2p/go-libp2p v0.23.4
github.com/mitchellh/go-homedir v1.1.0
github.com/mr-tron/base58 v1.2.0
github.com/mroth/weightedrand v0.4.1
github.com/multiformats/go-multiaddr v0.8.0
github.com/multiformats/go-multihash v0.2.1
Expand Down Expand Up @@ -169,7 +170,6 @@ require (
github.com/minio/blake2b-simd v0.0.0-20160723061019-3f5f724cb5b1 // indirect
github.com/minio/sha256-simd v1.0.0 // indirect
github.com/montanaflynn/stats v0.6.6 // indirect
github.com/mr-tron/base58 v1.2.0 // indirect
github.com/multiformats/go-base32 v0.1.0 // indirect
github.com/multiformats/go-base36 v0.1.0 // indirect
github.com/multiformats/go-multiaddr-dns v0.3.1 // indirect
Expand Down
14 changes: 12 additions & 2 deletions damocles-manager/modules/impl/prover/worker/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ func (api WdPoStAPIImpl) WdPoStRemoveJob(ctx context.Context, jobID string) (cor
return nil, err
}

func (api WdPoStAPIImpl) WdPoStAllJobs(ctx context.Context) ([]*core.WdPoStJob, error) {
return api.jobMgr.All(ctx, func(_ *core.WdPoStJob) bool { return true })
func (api WdPoStAPIImpl) WdPoStAllJobs(ctx context.Context) ([]*core.WdPoStJobBrief, error) {
jobs, err := api.jobMgr.All(ctx, func(_ *core.WdPoStJob) bool { return true })
if err != nil {
return nil, err
}
ret := make([]*core.WdPoStJobBrief, len(jobs))
for i, job := range jobs {
ret[i] = &core.WdPoStJobBrief{
WdPoStJob: *job,
}
}
return ret, nil
}

0 comments on commit 726eacc

Please sign in to comment.