diff --git a/Makefile b/Makefile index c8c010b..e379813 100644 --- a/Makefile +++ b/Makefile @@ -2,9 +2,6 @@ all: go-deps ui-deps ui go all-in-one: go-deps ui-deps ui go-dist aio: all-in-one -gen: - go generate ./... - cd ui && yarn graphql-codegen -c ../codegen.yml go-deps: git submodule update --init --recursive @@ -25,4 +22,17 @@ ui: lint: golangci-lint run -v ./... - cd ui && yarn lint \ No newline at end of file + cd ui && yarn lint + +curio-rpc-gen: + go run ./graph/curiorpc/gen + goimports -w graph/curiorpc +.PHONY: api-gen + +graph-type-gen: + cd ui && yarn graphql-codegen -c ../codegen.yml + +go-gen: + go generate ./... + +gen: go-gen curio-rpc-gen graph-type-gen diff --git a/go.mod b/go.mod index 61383fc..2e55ba4 100644 --- a/go.mod +++ b/go.mod @@ -34,6 +34,7 @@ require ( contrib.go.opencensus.io/exporter/prometheus v0.4.2 // indirect github.com/GeertJohan/go.incremental v1.0.0 // indirect github.com/GeertJohan/go.rice v1.0.3 // indirect + github.com/KarpelesLab/reflink v1.0.1 // indirect github.com/Kubuxu/imtui v0.0.0-20210401140320-41663d68d0fa // indirect github.com/StackExchange/wmi v1.2.1 // indirect github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d // indirect @@ -70,12 +71,14 @@ require ( github.com/filecoin-project/go-bitfield v0.2.4 // indirect github.com/filecoin-project/go-cbor-util v0.0.1 // indirect github.com/filecoin-project/go-commp-utils v0.1.3 // indirect + github.com/filecoin-project/go-commp-utils/nonffi v0.0.0-20220905160352-62059082a837 // indirect github.com/filecoin-project/go-crypto v0.0.1 // indirect github.com/filecoin-project/go-f3 v0.0.7 // indirect github.com/filecoin-project/go-fil-commcid v0.1.0 // indirect github.com/filecoin-project/go-hamt-ipld v0.1.5 // indirect github.com/filecoin-project/go-hamt-ipld/v2 v2.0.0 // indirect github.com/filecoin-project/go-hamt-ipld/v3 v3.1.0 // indirect + github.com/filecoin-project/go-padreader v0.0.1 // indirect github.com/filecoin-project/go-paramfetch v0.0.4 // indirect github.com/filecoin-project/go-state-types v0.14.0 // indirect github.com/filecoin-project/go-statestore v0.2.0 // indirect @@ -205,6 +208,7 @@ require ( github.com/shirou/gopsutil v2.18.12+incompatible // indirect github.com/sirupsen/logrus v1.9.2 // indirect github.com/smartystreets/assertions v1.13.0 // indirect + github.com/snadrus/must v0.0.0-20240605044437-98cedd57f8eb // indirect github.com/sosodev/duration v1.3.1 // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect github.com/stretchr/testify v1.9.0 // indirect diff --git a/go.sum b/go.sum index c5ea52d..127c4c1 100644 --- a/go.sum +++ b/go.sum @@ -46,6 +46,8 @@ github.com/GeertJohan/go.rice v1.0.3 h1:k5viR+xGtIhF61125vCE1cmJ5957RQGXG6dmbaWZ github.com/GeertJohan/go.rice v1.0.3/go.mod h1:XVdrU4pW00M4ikZed5q56tPf1v2KwnIKeIdc9CBYNt4= github.com/Gurpartap/async v0.0.0-20180927173644-4f7f499dd9ee h1:8doiS7ib3zi6/K172oDhSKU0dJ/miJramo9NITOMyZQ= github.com/Gurpartap/async v0.0.0-20180927173644-4f7f499dd9ee/go.mod h1:W0GbEAA4uFNYOGG2cJpmFJ04E6SD1NLELPYZB57/7AY= +github.com/KarpelesLab/reflink v1.0.1 h1:d+tdjliwOCqvub9bl0Y02GxahWkNqejNb3TZTTUcQWA= +github.com/KarpelesLab/reflink v1.0.1/go.mod h1:WGkTOKNjd1FsJKBw3mu4JvrPEDJyJJ+JPtxBkbPoCok= github.com/Kubuxu/go-os-helper v0.0.1/go.mod h1:N8B+I7vPCT80IcP58r50u4+gEEcsZETFUpAzWW2ep1Y= github.com/Kubuxu/imtui v0.0.0-20210401140320-41663d68d0fa h1:1PPxEyGdIGVkX/kqMvLJ95a1dGS1Sz7tpNEgehEYYt0= github.com/Kubuxu/imtui v0.0.0-20210401140320-41663d68d0fa/go.mod h1:WUmMvh9wMtqj1Xhf1hf3kp9RvL+y6odtdYxpyZjb90U= @@ -227,6 +229,8 @@ github.com/filecoin-project/go-hamt-ipld/v3 v3.1.0/go.mod h1:bxmzgT8tmeVQA1/gvBw github.com/filecoin-project/go-jsonrpc v0.6.1-0.20240820160949-2cfe810e5d2f h1:0FMH/uwBH7RinWrE+TkiOotYoqxSM54teKx/olJ/cWs= github.com/filecoin-project/go-jsonrpc v0.6.1-0.20240820160949-2cfe810e5d2f/go.mod h1:/n/niXcS4ZQua6i37LcVbY1TmlJR0UIK9mDFQq2ICek= github.com/filecoin-project/go-padreader v0.0.0-20200903213702-ed5fae088b20/go.mod h1:mPn+LRRd5gEKNAtc+r3ScpW2JRU/pj4NBKdADYWHiak= +github.com/filecoin-project/go-padreader v0.0.1 h1:8h2tVy5HpoNbr2gBRr+WD6zV6VD6XHig+ynSGJg8ZOs= +github.com/filecoin-project/go-padreader v0.0.1/go.mod h1:VYVPJqwpsfmtoHnAmPx6MUwmrK6HIcDqZJiuZhtmfLQ= github.com/filecoin-project/go-paramfetch v0.0.4 h1:H+Me8EL8T5+79z/KHYQQcT8NVOzYVqXIi7nhb48tdm8= github.com/filecoin-project/go-paramfetch v0.0.4/go.mod h1:1FH85P8U+DUEmWk1Jkw3Bw7FrwTVUNHk/95PSPG+dts= github.com/filecoin-project/go-state-types v0.0.0-20200903145444-247639ffa6ad/go.mod h1:IQ0MBPnonv35CJHtWSN3YY1Hz2gkPru1Q9qoaYLxx9I= diff --git a/graph/curiorpc/client.go b/graph/curiorpc/client.go new file mode 100644 index 0000000..55d7887 --- /dev/null +++ b/graph/curiorpc/client.go @@ -0,0 +1,17 @@ +package curiorpc + +import ( + "context" + "net/http" + + "github.com/filecoin-project/go-jsonrpc" + "github.com/filecoin-project/lotus/api" +) + +func NewWebRPCV0(ctx context.Context, addr string, requestHeader http.Header) (WebRPC, jsonrpc.ClientCloser, error) { + var res WebRPCStruct + closer, err := jsonrpc.NewMergeClient(ctx, addr, "CurioWeb", + api.GetInternalStructs(&res), requestHeader, jsonrpc.WithErrors(api.RPCErrors)) + + return &res, closer, err +} diff --git a/graph/curiorpc/gen/proxygen.go b/graph/curiorpc/gen/proxygen.go new file mode 100644 index 0000000..0d33976 --- /dev/null +++ b/graph/curiorpc/gen/proxygen.go @@ -0,0 +1,344 @@ +package main + +import ( + "fmt" + "go/ast" + "go/parser" + "go/token" + "io" + "os" + "path/filepath" + "strings" + "text/template" + + "golang.org/x/xerrors" +) + +type methodMeta struct { + node ast.Node + ftype *ast.FuncType +} + +type Visitor struct { + Methods map[string]map[string]*methodMeta + Include map[string][]string +} + +func (v *Visitor) Visit(node ast.Node) ast.Visitor { + st, ok := node.(*ast.TypeSpec) + if !ok { + return v + } + + iface, ok := st.Type.(*ast.InterfaceType) + if !ok { + return v + } + if v.Methods[st.Name.Name] == nil { + v.Methods[st.Name.Name] = map[string]*methodMeta{} + } + for _, m := range iface.Methods.List { + switch ft := m.Type.(type) { + case *ast.Ident: + v.Include[st.Name.Name] = append(v.Include[st.Name.Name], ft.Name) + case *ast.FuncType: + v.Methods[st.Name.Name][m.Names[0].Name] = &methodMeta{ + node: m, + ftype: ft, + } + } + } + + return v +} + +func main() { + if err := generate("./graph/curiorpc", "curiorpc", "curiorpc", "./graph/curiorpc/proxy_gen.go"); err != nil { + fmt.Println("error: ", err) + } +} + +func typeName(e ast.Expr, pkg string) (string, error) { + switch t := e.(type) { + case *ast.SelectorExpr: + return t.X.(*ast.Ident).Name + "." + t.Sel.Name, nil + case *ast.Ident: + pstr := t.Name + return pstr, nil + case *ast.ArrayType: + subt, err := typeName(t.Elt, pkg) + if err != nil { + return "", err + } + return "[]" + subt, nil + case *ast.StarExpr: + subt, err := typeName(t.X, pkg) + if err != nil { + return "", err + } + return "*" + subt, nil + case *ast.MapType: + k, err := typeName(t.Key, pkg) + if err != nil { + return "", err + } + v, err := typeName(t.Value, pkg) + if err != nil { + return "", err + } + return "map[" + k + "]" + v, nil + case *ast.StructType: + if len(t.Fields.List) != 0 { + return "", xerrors.Errorf("can't struct") + } + return "struct{}", nil + case *ast.InterfaceType: + if len(t.Methods.List) != 0 { + return "", xerrors.Errorf("can't interface") + } + return "interface{}", nil + case *ast.ChanType: + subt, err := typeName(t.Value, pkg) + if err != nil { + return "", err + } + if t.Dir == ast.SEND { + subt = "->chan " + subt + } else { + subt = "<-chan " + subt + } + return subt, nil + default: + return "", xerrors.Errorf("unknown type") + } +} + +func generate(path, pkg, outpkg, outfile string) error { + fset := token.NewFileSet() + apiDir, err := filepath.Abs(path) + if err != nil { + return err + } + outfile, err = filepath.Abs(outfile) + if err != nil { + return err + } + pkgs, err := parser.ParseDir(fset, apiDir, nil, parser.AllErrors|parser.ParseComments) + if err != nil { + return err + } + + ap := pkgs[pkg] + + v := &Visitor{make(map[string]map[string]*methodMeta), map[string][]string{}} + ast.Walk(v, ap) + + type methodInfo struct { + Num string + node ast.Node + Tags map[string][]string + NamedParams, ParamNames, Results, DefRes string + } + + type strinfo struct { + Num string + Methods map[string]*methodInfo + Include []string + } + + type meta struct { + Infos map[string]*strinfo + Imports map[string]string + OutPkg string + } + + m := &meta{ + OutPkg: outpkg, + Infos: map[string]*strinfo{}, + Imports: map[string]string{}, + } + + for fn, f := range ap.Files { + if strings.HasSuffix(fn, "gen.go") { + continue + } + + //fmt.Println("F:", fn) + cmap := ast.NewCommentMap(fset, f, f.Comments) + + for _, im := range f.Imports { + m.Imports[im.Path.Value] = im.Path.Value + if im.Name != nil { + m.Imports[im.Path.Value] = im.Name.Name + " " + m.Imports[im.Path.Value] + } + } + + for ifname, methods := range v.Methods { + if _, ok := m.Infos[ifname]; !ok { + m.Infos[ifname] = &strinfo{ + Num: ifname, + Methods: map[string]*methodInfo{}, + Include: v.Include[ifname], + } + } + info := m.Infos[ifname] + for mname, node := range methods { + filteredComments := cmap.Filter(node.node).Comments() + + if _, ok := info.Methods[mname]; !ok { + var params, pnames []string + for _, param := range node.ftype.Params.List { + pstr, err := typeName(param.Type, outpkg) + if err != nil { + return err + } + + c := len(param.Names) + if c == 0 { + c = 1 + } + + for i := 0; i < c; i++ { + pname := fmt.Sprintf("p%d", len(params)) + pnames = append(pnames, pname) + params = append(params, pname+" "+pstr) + } + } + + results := []string{} + for _, result := range node.ftype.Results.List { + rs, err := typeName(result.Type, outpkg) + if err != nil { + return err + } + results = append(results, rs) + } + + defRes := "" + if len(results) > 1 { + defRes = results[0] + switch { + case defRes[0] == '*' || defRes[0] == '<', defRes == "interface{}": + defRes = "nil" + case defRes == "bool": + defRes = "false" + case defRes == "string": + defRes = `""` + case defRes == "int", defRes == "int64", defRes == "uint64", defRes == "uint": + defRes = "0" + default: + defRes = "*new(" + defRes + ")" + } + defRes += ", " + } + + info.Methods[mname] = &methodInfo{ + Num: mname, + node: node.node, + Tags: map[string][]string{}, + NamedParams: strings.Join(params, ", "), + ParamNames: strings.Join(pnames, ", "), + Results: strings.Join(results, ", "), + DefRes: defRes, + } + } + + // try to parse tag info + if len(filteredComments) > 0 { + tagstr := filteredComments[len(filteredComments)-1].List[0].Text + tagstr = strings.TrimPrefix(tagstr, "//") + tl := strings.Split(strings.TrimSpace(tagstr), " ") + for _, ts := range tl { + tf := strings.Split(ts, ":") + if len(tf) != 2 { + continue + } + if tf[0] != "perm" && tf[0] != "rpc_method" && tf[0] != "notify" { // todo: allow more tag types + continue + } + info.Methods[mname].Tags[tf[0]] = tf + } + } + } + } + } + + /*jb, err := json.MarshalIndent(Infos, "", " ") + if err != nil { + return err + } + fmt.Println(string(jb))*/ + + w, err := os.OpenFile(outfile, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0666) + if err != nil { + return err + } + + err = doTemplate(w, m, `// Code generated by github.com/filecoin-project/lotus/gen/api. DO NOT EDIT. + +package {{.OutPkg}} + +import ( +{{range .Imports}} {{.}} +{{end}} +) +`) + if err != nil { + return err + } + + err = doTemplate(w, m, ` + +var ErrNotSupported = xerrors.New("method not supported") + +{{range .Infos}} +type {{.Num}}Struct struct { +{{range .Include}} + {{.}}Struct +{{end}} + Internal {{.Num}}Methods +} + +type {{.Num}}Methods struct { +{{range .Methods}} + {{.Num}} func({{.NamedParams}}) ({{.Results}}) `+"`"+`{{$first := true}}{{range .Tags}}{{if $first}}{{$first = false}}{{else}} {{end}}{{index . 0}}:"{{index . 1}}"{{end}}`+"`"+` + +{{end}} + } + +type {{.Num}}Stub struct { +{{range .Include}} + {{.}}Stub +{{end}} +} +{{end}} + +{{range .Infos}} +{{$name := .Num}} +{{range .Methods}} +func (s *{{$name}}Struct) {{.Num}}({{.NamedParams}}) ({{.Results}}) { + if s.Internal.{{.Num}} == nil { + return {{.DefRes}}ErrNotSupported + } + return s.Internal.{{.Num}}({{.ParamNames}}) +} + +func (s *{{$name}}Stub) {{.Num}}({{.NamedParams}}) ({{.Results}}) { + return {{.DefRes}}ErrNotSupported +} +{{end}} +{{end}} + +{{range .Infos}}var _ {{.Num}} = new({{.Num}}Struct) +{{end}} + +`) + return err +} + +func doTemplate(w io.Writer, info interface{}, templ string) error { + t := template.Must(template.New(""). + Funcs(template.FuncMap{}).Parse(templ)) + + return t.Execute(w, info) +} diff --git a/graph/curiorpc/proxy_gen.go b/graph/curiorpc/proxy_gen.go new file mode 100644 index 0000000..a90b005 --- /dev/null +++ b/graph/curiorpc/proxy_gen.go @@ -0,0 +1,362 @@ +// Code generated by github.com/filecoin-project/lotus/gen/api. DO NOT EDIT. + +package curiorpc + +import ( + "context" + + "github.com/filecoin-project/curio/web/api/webrpc" + "github.com/filecoin-project/go-address" + "golang.org/x/xerrors" +) + +var ErrNotSupported = xerrors.New("method not supported") + +type WebRPCStruct struct { + Internal WebRPCMethods +} + +type WebRPCMethods struct { + ActorList func(p0 context.Context) ([]string, error) `` + + ActorSectorExpirations func(p0 context.Context, p1 address.Address) (*webrpc.SectorExpirations, error) `` + + ActorSummary func(p0 context.Context) ([]webrpc.ActorSummary, error) `` + + ClusterMachines func(p0 context.Context) ([]webrpc.MachineSummary, error) `` + + ClusterNodeInfo func(p0 context.Context, p1 int64) (*webrpc.MachineInfo, error) `` + + ClusterTaskHistory func(p0 context.Context) ([]webrpc.TaskHistorySummary, error) `` + + ClusterTaskSummary func(p0 context.Context) ([]webrpc.TaskSummary, error) `` + + DealsPending func(p0 context.Context) ([]webrpc.OpenDealInfo, error) `` + + DealsSealNow func(p0 context.Context, p1 uint64, p2 uint64) error `` + + HarmonyTaskHistory func(p0 context.Context, p1 string) ([]webrpc.HarmonyTaskHistory, error) `` + + HarmonyTaskMachines func(p0 context.Context, p1 string) ([]webrpc.HarmonyMachineDesc, error) `` + + HarmonyTaskStats func(p0 context.Context) ([]webrpc.HarmonyTaskStats, error) `` + + PipelinePorepSectors func(p0 context.Context) ([]sectorListEntry, error) `` + + PorepPipelineSummary func(p0 context.Context) ([]webrpc.PorepPipelineSummary, error) `` + + SectorInfo func(p0 context.Context, p1 string, p2 int64) (*webrpc.SectorInfo, error) `` + + SectorRemove func(p0 context.Context, p1 int, p2 int) error `` + + StorageGCApprove func(p0 context.Context, p1 int64, p2 int64, p3 int64, p4 string) error `` + + StorageGCApproveAll func(p0 context.Context) error `` + + StorageGCMarks func(p0 context.Context) ([]webrpc.StorageGCMarks, error) `` + + StorageGCUnapproveAll func(p0 context.Context) error `` + + StorageUseStats func(p0 context.Context) ([]webrpc.StorageUseStats, error) `` + + SyncerState func(p0 context.Context) ([]webrpc.RpcInfo, error) `` + + UpgradeDelete func(p0 context.Context, p1 uint64, p2 uint64) error `` + + UpgradeResetTaskIDs func(p0 context.Context, p1 uint64, p2 uint64) error `` + + UpgradeSectors func(p0 context.Context) ([]webrpc.UpgradeSector, error) `` + + WinStats func(p0 context.Context) ([]webrpc.WinStats, error) `` +} + +type WebRPCStub struct { +} + +func (s *WebRPCStruct) ActorList(p0 context.Context) ([]string, error) { + if s.Internal.ActorList == nil { + return *new([]string), ErrNotSupported + } + return s.Internal.ActorList(p0) +} + +func (s *WebRPCStub) ActorList(p0 context.Context) ([]string, error) { + return *new([]string), ErrNotSupported +} + +func (s *WebRPCStruct) ActorSectorExpirations(p0 context.Context, p1 address.Address) (*webrpc.SectorExpirations, error) { + if s.Internal.ActorSectorExpirations == nil { + return nil, ErrNotSupported + } + return s.Internal.ActorSectorExpirations(p0, p1) +} + +func (s *WebRPCStub) ActorSectorExpirations(p0 context.Context, p1 address.Address) (*webrpc.SectorExpirations, error) { + return nil, ErrNotSupported +} + +func (s *WebRPCStruct) ActorSummary(p0 context.Context) ([]webrpc.ActorSummary, error) { + if s.Internal.ActorSummary == nil { + return *new([]webrpc.ActorSummary), ErrNotSupported + } + return s.Internal.ActorSummary(p0) +} + +func (s *WebRPCStub) ActorSummary(p0 context.Context) ([]webrpc.ActorSummary, error) { + return *new([]webrpc.ActorSummary), ErrNotSupported +} + +func (s *WebRPCStruct) ClusterMachines(p0 context.Context) ([]webrpc.MachineSummary, error) { + if s.Internal.ClusterMachines == nil { + return *new([]webrpc.MachineSummary), ErrNotSupported + } + return s.Internal.ClusterMachines(p0) +} + +func (s *WebRPCStub) ClusterMachines(p0 context.Context) ([]webrpc.MachineSummary, error) { + return *new([]webrpc.MachineSummary), ErrNotSupported +} + +func (s *WebRPCStruct) ClusterNodeInfo(p0 context.Context, p1 int64) (*webrpc.MachineInfo, error) { + if s.Internal.ClusterNodeInfo == nil { + return nil, ErrNotSupported + } + return s.Internal.ClusterNodeInfo(p0, p1) +} + +func (s *WebRPCStub) ClusterNodeInfo(p0 context.Context, p1 int64) (*webrpc.MachineInfo, error) { + return nil, ErrNotSupported +} + +func (s *WebRPCStruct) ClusterTaskHistory(p0 context.Context) ([]webrpc.TaskHistorySummary, error) { + if s.Internal.ClusterTaskHistory == nil { + return *new([]webrpc.TaskHistorySummary), ErrNotSupported + } + return s.Internal.ClusterTaskHistory(p0) +} + +func (s *WebRPCStub) ClusterTaskHistory(p0 context.Context) ([]webrpc.TaskHistorySummary, error) { + return *new([]webrpc.TaskHistorySummary), ErrNotSupported +} + +func (s *WebRPCStruct) ClusterTaskSummary(p0 context.Context) ([]webrpc.TaskSummary, error) { + if s.Internal.ClusterTaskSummary == nil { + return *new([]webrpc.TaskSummary), ErrNotSupported + } + return s.Internal.ClusterTaskSummary(p0) +} + +func (s *WebRPCStub) ClusterTaskSummary(p0 context.Context) ([]webrpc.TaskSummary, error) { + return *new([]webrpc.TaskSummary), ErrNotSupported +} + +func (s *WebRPCStruct) DealsPending(p0 context.Context) ([]webrpc.OpenDealInfo, error) { + if s.Internal.DealsPending == nil { + return *new([]webrpc.OpenDealInfo), ErrNotSupported + } + return s.Internal.DealsPending(p0) +} + +func (s *WebRPCStub) DealsPending(p0 context.Context) ([]webrpc.OpenDealInfo, error) { + return *new([]webrpc.OpenDealInfo), ErrNotSupported +} + +func (s *WebRPCStruct) DealsSealNow(p0 context.Context, p1 uint64, p2 uint64) error { + if s.Internal.DealsSealNow == nil { + return ErrNotSupported + } + return s.Internal.DealsSealNow(p0, p1, p2) +} + +func (s *WebRPCStub) DealsSealNow(p0 context.Context, p1 uint64, p2 uint64) error { + return ErrNotSupported +} + +func (s *WebRPCStruct) HarmonyTaskHistory(p0 context.Context, p1 string) ([]webrpc.HarmonyTaskHistory, error) { + if s.Internal.HarmonyTaskHistory == nil { + return *new([]webrpc.HarmonyTaskHistory), ErrNotSupported + } + return s.Internal.HarmonyTaskHistory(p0, p1) +} + +func (s *WebRPCStub) HarmonyTaskHistory(p0 context.Context, p1 string) ([]webrpc.HarmonyTaskHistory, error) { + return *new([]webrpc.HarmonyTaskHistory), ErrNotSupported +} + +func (s *WebRPCStruct) HarmonyTaskMachines(p0 context.Context, p1 string) ([]webrpc.HarmonyMachineDesc, error) { + if s.Internal.HarmonyTaskMachines == nil { + return *new([]webrpc.HarmonyMachineDesc), ErrNotSupported + } + return s.Internal.HarmonyTaskMachines(p0, p1) +} + +func (s *WebRPCStub) HarmonyTaskMachines(p0 context.Context, p1 string) ([]webrpc.HarmonyMachineDesc, error) { + return *new([]webrpc.HarmonyMachineDesc), ErrNotSupported +} + +func (s *WebRPCStruct) HarmonyTaskStats(p0 context.Context) ([]webrpc.HarmonyTaskStats, error) { + if s.Internal.HarmonyTaskStats == nil { + return *new([]webrpc.HarmonyTaskStats), ErrNotSupported + } + return s.Internal.HarmonyTaskStats(p0) +} + +func (s *WebRPCStub) HarmonyTaskStats(p0 context.Context) ([]webrpc.HarmonyTaskStats, error) { + return *new([]webrpc.HarmonyTaskStats), ErrNotSupported +} + +func (s *WebRPCStruct) PipelinePorepSectors(p0 context.Context) ([]sectorListEntry, error) { + if s.Internal.PipelinePorepSectors == nil { + return *new([]sectorListEntry), ErrNotSupported + } + return s.Internal.PipelinePorepSectors(p0) +} + +func (s *WebRPCStub) PipelinePorepSectors(p0 context.Context) ([]sectorListEntry, error) { + return *new([]sectorListEntry), ErrNotSupported +} + +func (s *WebRPCStruct) PorepPipelineSummary(p0 context.Context) ([]webrpc.PorepPipelineSummary, error) { + if s.Internal.PorepPipelineSummary == nil { + return *new([]webrpc.PorepPipelineSummary), ErrNotSupported + } + return s.Internal.PorepPipelineSummary(p0) +} + +func (s *WebRPCStub) PorepPipelineSummary(p0 context.Context) ([]webrpc.PorepPipelineSummary, error) { + return *new([]webrpc.PorepPipelineSummary), ErrNotSupported +} + +func (s *WebRPCStruct) SectorInfo(p0 context.Context, p1 string, p2 int64) (*webrpc.SectorInfo, error) { + if s.Internal.SectorInfo == nil { + return nil, ErrNotSupported + } + return s.Internal.SectorInfo(p0, p1, p2) +} + +func (s *WebRPCStub) SectorInfo(p0 context.Context, p1 string, p2 int64) (*webrpc.SectorInfo, error) { + return nil, ErrNotSupported +} + +func (s *WebRPCStruct) SectorRemove(p0 context.Context, p1 int, p2 int) error { + if s.Internal.SectorRemove == nil { + return ErrNotSupported + } + return s.Internal.SectorRemove(p0, p1, p2) +} + +func (s *WebRPCStub) SectorRemove(p0 context.Context, p1 int, p2 int) error { + return ErrNotSupported +} + +func (s *WebRPCStruct) StorageGCApprove(p0 context.Context, p1 int64, p2 int64, p3 int64, p4 string) error { + if s.Internal.StorageGCApprove == nil { + return ErrNotSupported + } + return s.Internal.StorageGCApprove(p0, p1, p2, p3, p4) +} + +func (s *WebRPCStub) StorageGCApprove(p0 context.Context, p1 int64, p2 int64, p3 int64, p4 string) error { + return ErrNotSupported +} + +func (s *WebRPCStruct) StorageGCApproveAll(p0 context.Context) error { + if s.Internal.StorageGCApproveAll == nil { + return ErrNotSupported + } + return s.Internal.StorageGCApproveAll(p0) +} + +func (s *WebRPCStub) StorageGCApproveAll(p0 context.Context) error { + return ErrNotSupported +} + +func (s *WebRPCStruct) StorageGCMarks(p0 context.Context) ([]webrpc.StorageGCMarks, error) { + if s.Internal.StorageGCMarks == nil { + return *new([]webrpc.StorageGCMarks), ErrNotSupported + } + return s.Internal.StorageGCMarks(p0) +} + +func (s *WebRPCStub) StorageGCMarks(p0 context.Context) ([]webrpc.StorageGCMarks, error) { + return *new([]webrpc.StorageGCMarks), ErrNotSupported +} + +func (s *WebRPCStruct) StorageGCUnapproveAll(p0 context.Context) error { + if s.Internal.StorageGCUnapproveAll == nil { + return ErrNotSupported + } + return s.Internal.StorageGCUnapproveAll(p0) +} + +func (s *WebRPCStub) StorageGCUnapproveAll(p0 context.Context) error { + return ErrNotSupported +} + +func (s *WebRPCStruct) StorageUseStats(p0 context.Context) ([]webrpc.StorageUseStats, error) { + if s.Internal.StorageUseStats == nil { + return *new([]webrpc.StorageUseStats), ErrNotSupported + } + return s.Internal.StorageUseStats(p0) +} + +func (s *WebRPCStub) StorageUseStats(p0 context.Context) ([]webrpc.StorageUseStats, error) { + return *new([]webrpc.StorageUseStats), ErrNotSupported +} + +func (s *WebRPCStruct) SyncerState(p0 context.Context) ([]webrpc.RpcInfo, error) { + if s.Internal.SyncerState == nil { + return *new([]webrpc.RpcInfo), ErrNotSupported + } + return s.Internal.SyncerState(p0) +} + +func (s *WebRPCStub) SyncerState(p0 context.Context) ([]webrpc.RpcInfo, error) { + return *new([]webrpc.RpcInfo), ErrNotSupported +} + +func (s *WebRPCStruct) UpgradeDelete(p0 context.Context, p1 uint64, p2 uint64) error { + if s.Internal.UpgradeDelete == nil { + return ErrNotSupported + } + return s.Internal.UpgradeDelete(p0, p1, p2) +} + +func (s *WebRPCStub) UpgradeDelete(p0 context.Context, p1 uint64, p2 uint64) error { + return ErrNotSupported +} + +func (s *WebRPCStruct) UpgradeResetTaskIDs(p0 context.Context, p1 uint64, p2 uint64) error { + if s.Internal.UpgradeResetTaskIDs == nil { + return ErrNotSupported + } + return s.Internal.UpgradeResetTaskIDs(p0, p1, p2) +} + +func (s *WebRPCStub) UpgradeResetTaskIDs(p0 context.Context, p1 uint64, p2 uint64) error { + return ErrNotSupported +} + +func (s *WebRPCStruct) UpgradeSectors(p0 context.Context) ([]webrpc.UpgradeSector, error) { + if s.Internal.UpgradeSectors == nil { + return *new([]webrpc.UpgradeSector), ErrNotSupported + } + return s.Internal.UpgradeSectors(p0) +} + +func (s *WebRPCStub) UpgradeSectors(p0 context.Context) ([]webrpc.UpgradeSector, error) { + return *new([]webrpc.UpgradeSector), ErrNotSupported +} + +func (s *WebRPCStruct) WinStats(p0 context.Context) ([]webrpc.WinStats, error) { + if s.Internal.WinStats == nil { + return *new([]webrpc.WinStats), ErrNotSupported + } + return s.Internal.WinStats(p0) +} + +func (s *WebRPCStub) WinStats(p0 context.Context) ([]webrpc.WinStats, error) { + return *new([]webrpc.WinStats), ErrNotSupported +} + +var _ WebRPC = new(WebRPCStruct) diff --git a/graph/curiorpc/webrpc.go b/graph/curiorpc/webrpc.go new file mode 100644 index 0000000..f62b40a --- /dev/null +++ b/graph/curiorpc/webrpc.go @@ -0,0 +1,47 @@ +package curiorpc + +import ( + "context" + + "github.com/filecoin-project/curio/web/api/webrpc" + "github.com/filecoin-project/go-address" +) + +type WebRPC interface { + ActorSectorExpirations(ctx context.Context, maddr address.Address) (*webrpc.SectorExpirations, error) + ActorSummary(ctx context.Context) ([]webrpc.ActorSummary, error) + ActorList(ctx context.Context) ([]string, error) + ClusterMachines(ctx context.Context) ([]webrpc.MachineSummary, error) + ClusterTaskHistory(ctx context.Context) ([]webrpc.TaskHistorySummary, error) + ClusterNodeInfo(ctx context.Context, id int64) (*webrpc.MachineInfo, error) + DealsPending(ctx context.Context) ([]webrpc.OpenDealInfo, error) + DealsSealNow(ctx context.Context, spId, sectorNumber uint64) error + HarmonyTaskStats(ctx context.Context) ([]webrpc.HarmonyTaskStats, error) + HarmonyTaskMachines(ctx context.Context, taskName string) ([]webrpc.HarmonyMachineDesc, error) + HarmonyTaskHistory(ctx context.Context, taskName string) ([]webrpc.HarmonyTaskHistory, error) + PipelinePorepSectors(ctx context.Context) ([]sectorListEntry, error) + PorepPipelineSummary(ctx context.Context) ([]webrpc.PorepPipelineSummary, error) + SectorInfo(ctx context.Context, sp string, intid int64) (*webrpc.SectorInfo, error) + SectorRemove(ctx context.Context, spid, id int) error + StorageUseStats(ctx context.Context) ([]webrpc.StorageUseStats, error) + StorageGCMarks(ctx context.Context) ([]webrpc.StorageGCMarks, error) + StorageGCApprove(ctx context.Context, actor int64, sectorNum int64, fileType int64, storageID string) error + StorageGCApproveAll(ctx context.Context) error + StorageGCUnapproveAll(ctx context.Context) error + SyncerState(ctx context.Context) ([]webrpc.RpcInfo, error) + ClusterTaskSummary(ctx context.Context) ([]webrpc.TaskSummary, error) + UpgradeSectors(ctx context.Context) ([]webrpc.UpgradeSector, error) + UpgradeResetTaskIDs(ctx context.Context, spid, sectorNum uint64) error + UpgradeDelete(ctx context.Context, spid, sectorNum uint64) error + WinStats(ctx context.Context) ([]webrpc.WinStats, error) +} + +type sectorListEntry struct { + webrpc.PipelineTask + + Address address.Address + CreateTime string + AfterSeed bool + + ChainAlloc, ChainSector, ChainActive, ChainUnproven, ChainFaulty bool +} diff --git a/graph/resolvers/subscription.go b/graph/resolvers/subscription.go index 78cb576..7369423 100644 --- a/graph/resolvers/subscription.go +++ b/graph/resolvers/subscription.go @@ -6,6 +6,7 @@ package resolvers import ( "context" + "github.com/strahe/curio-dashboard/graph" "github.com/strahe/curio-dashboard/graph/model" ) diff --git a/ui/yarn.lock b/ui/yarn.lock index b47f5a6..a441e44 100644 --- a/ui/yarn.lock +++ b/ui/yarn.lock @@ -22,15 +22,7 @@ resolved "https://registry.npmmirror.com/@ant-design/icons-svg/-/icons-svg-4.4.2.tgz" integrity sha512-vHbT+zJEVzllwP+CM+ul7reTEfBR0vgxFe7+lREAsAA7YGsYpboiq2sQNeQeRvh09GfQgs/GyFEvZpJ9cLXpXA== -"@ant-design/icons-vue@^7.0.0": - version "7.0.1" - resolved "https://registry.npmmirror.com/@ant-design/icons-vue/-/icons-vue-7.0.1.tgz" - integrity sha512-eCqY2unfZK6Fe02AwFlDHLfoyEFreP6rBwAZMIJ1LugmfMiVgwWDYlp1YsRugaPtICYOabV1iWxXdP12u9U43Q== - dependencies: - "@ant-design/colors" "^6.0.0" - "@ant-design/icons-svg" "^4.2.1" - -"@ant-design/icons-vue@^7.0.1": +"@ant-design/icons-vue@^7.0.0", "@ant-design/icons-vue@^7.0.1": version "7.0.1" resolved "https://registry.npmmirror.com/@ant-design/icons-vue/-/icons-vue-7.0.1.tgz#83de301771fadd03f3890e627314102405c31c22" integrity sha512-eCqY2unfZK6Fe02AwFlDHLfoyEFreP6rBwAZMIJ1LugmfMiVgwWDYlp1YsRugaPtICYOabV1iWxXdP12u9U43Q==