diff --git a/damocles-manager/core/api.go b/damocles-manager/core/api.go index 3c8dce840..66a6a2d0a 100644 --- a/damocles-manager/core/api.go +++ b/damocles-manager/core/api.go @@ -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) } diff --git a/damocles-manager/core/types_wdpost.go b/damocles-manager/core/types_wdpost.go index 5a0627901..e4579b57e 100644 --- a/damocles-manager/core/types_wdpost.go +++ b/damocles-manager/core/types_wdpost.go @@ -2,6 +2,7 @@ package core import ( "context" + "encoding/json" "time" "github.com/filecoin-project/go-state-types/abi" @@ -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 diff --git a/damocles-manager/go.mod b/damocles-manager/go.mod index bb9659518..c0bd53c10 100644 --- a/damocles-manager/go.mod +++ b/damocles-manager/go.mod @@ -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 @@ -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 diff --git a/damocles-manager/modules/impl/prover/worker/rpc.go b/damocles-manager/modules/impl/prover/worker/rpc.go index d3879ed3a..e5a956fc5 100644 --- a/damocles-manager/modules/impl/prover/worker/rpc.go +++ b/damocles-manager/modules/impl/prover/worker/rpc.go @@ -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 }