diff --git a/api/api_storage.go b/api/api_storage.go index 3e2eac3ca..e39acd034 100644 --- a/api/api_storage.go +++ b/api/api_storage.go @@ -355,12 +355,12 @@ type DealSchedule struct { type DagstoreShardInfo struct { Key string State string - Error error + Error string } // DagstoreGCResult is the serialized form of dagstore.GCResult that we expose // through JSON-RPC to avoid clients having to depend on the dagstore lib. type DagstoreGCResult struct { Key string - Error error + Error string } diff --git a/api/api_test.go b/api/api_test.go index 738e1b067..e65d50ca3 100644 --- a/api/api_test.go +++ b/api/api_test.go @@ -76,7 +76,7 @@ func TestReturnTypes(t *testing.T) { seen[typ] = struct{}{} if typ.Kind() == reflect.Interface && typ != bareIface && !typ.Implements(jmarsh) { - t.Error("methods can't return interfaces", m.Name) + t.Error("methods can't return interfaces or struct types not implementing json.Marshaller", m.Name) } switch typ.Kind() { diff --git a/api/docgen/docgen.go b/api/docgen/docgen.go index 41968ef4a..8e16e2d42 100644 --- a/api/docgen/docgen.go +++ b/api/docgen/docgen.go @@ -278,12 +278,12 @@ func init() { }) addExample(api.DagstoreGCResult{ Key: "baga6ea4seaqecmtz7iak33dsfshi627abz4i4665dfuzr3qfs4bmad6dx3iigdq", - Error: nil, + Error: "", }) addExample(api.DagstoreShardInfo{ Key: "baga6ea4seaqecmtz7iak33dsfshi627abz4i4665dfuzr3qfs4bmad6dx3iigdq", State: "ShardStateAvailable", - Error: nil, + Error: "", }) } diff --git a/build/openrpc/miner.json.gz b/build/openrpc/miner.json.gz index 2c0dbb082..266112d07 100644 Binary files a/build/openrpc/miner.json.gz and b/build/openrpc/miner.json.gz differ diff --git a/cmd/lotus-miner/dagstore.go b/cmd/lotus-miner/dagstore.go index 38247ce2e..52a52f2cb 100644 --- a/cmd/lotus-miner/dagstore.go +++ b/cmd/lotus-miner/dagstore.go @@ -118,7 +118,7 @@ var dagstoreGcCmd = &cli.Command{ } for _, e := range collected { - if e.Error == nil { + if e.Error == "" { _, _ = fmt.Fprintln(os.Stdout, e.Key, "success") } else { _, _ = fmt.Fprintln(os.Stdout, e.Key, "failed:", e.Error) diff --git a/node/impl/storminer.go b/node/impl/storminer.go index 6e222820a..b286b39f9 100644 --- a/node/impl/storminer.go +++ b/node/impl/storminer.go @@ -564,7 +564,12 @@ func (sm *StorageMinerAPI) DagstoreListShards(ctx context.Context) ([]api.Dagsto ret = append(ret, api.DagstoreShardInfo{ Key: k.String(), State: i.ShardState.String(), - Error: i.Error, + Error: func() string { + if i.Error == nil { + return "" + } + return i.Error.Error() + }(), }) } return ret, nil @@ -624,8 +629,13 @@ func (sm *StorageMinerAPI) DagstoreGC(ctx context.Context) ([]api.DagstoreGCResu ret := make([]api.DagstoreGCResult, 0, len(res.Shards)) for k, err := range res.Shards { ret = append(ret, api.DagstoreGCResult{ - Key: k.String(), - Error: err, + Key: k.String(), + Error: func() string { + if err == nil { + return "" + } + return err.Error() + }(), }) }