Skip to content

Commit

Permalink
pick venus-gateway def & api
Browse files Browse the repository at this point in the history
  • Loading branch information
ta0li committed Feb 15, 2022
1 parent 7ba45e0 commit 6eacc83
Show file tree
Hide file tree
Showing 7 changed files with 148 additions and 0 deletions.
11 changes: 11 additions & 0 deletions venus-devtool/api-gen/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"reflect"

"github.com/filecoin-project/venus/venus-devtool/util"
"github.com/filecoin-project/venus/venus-shared/api/gateway"
"github.com/filecoin-project/venus/venus-shared/api/messager"
"github.com/filecoin-project/venus/venus-shared/api/wallet"
)
Expand All @@ -29,6 +30,16 @@ func init() {
MethodNamespace: "Message",
},
},
util.APIMeta{
Type: reflect.TypeOf((*gateway.IProofEventAPI)(nil)).Elem(),
ParseOpt: util.InterfaceParseOption{
ImportPath: "github.com/filecoin-project/venus/venus-shared/api/gateway",
IncludeAll: true,
},
RPCMeta: util.RPCMeta{
MethodNamespace: "Gateway",
},
},
util.APIMeta{
Type: reflect.TypeOf((*wallet.IFullAPI)(nil)).Elem(),
ParseOpt: util.InterfaceParseOption{
Expand Down
3 changes: 3 additions & 0 deletions venus-devtool/api-gen/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,9 @@ func exampleStruct(method string, t, parent reflect.Type) interface{} {
if f.Type == parent {
continue
}
if f.Type.Kind() == reflect.Chan {
continue
}
if strings.Title(f.Name) == f.Name {
ns.Elem().Field(i).Set(reflect.ValueOf(ExampleValue(method, f.Type, t)))
}
Expand Down
12 changes: 12 additions & 0 deletions venus-shared/api/gateway/api.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package gateway

import (
"context"

"github.com/filecoin-project/venus/venus-shared/types/gateway"
)

type IProofEventAPI interface {
ResponseProofEvent(ctx context.Context, resp *gateway.ResponseEvent) error //perm:write
ListenProofEvent(ctx context.Context, policy *gateway.ProofRegisterPolicy) (<-chan *gateway.RequestEvent, error) //perm:write
}
24 changes: 24 additions & 0 deletions venus-shared/api/gateway/client_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 49 additions & 0 deletions venus-shared/api/gateway/method.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Groups

* [ProofEvent](#ProofEvent)
* [ListenProofEvent](#ListenProofEvent)
* [ResponseProofEvent](#ResponseProofEvent)

## ProofEvent

### ListenProofEvent


Perms: write

Inputs:
```json
[
{
"MinerAddress": "f01234"
}
]
```

Response:
```json
{
"Id": "07070707-0707-0707-0707-070707070707",
"Method": "string value",
"Payload": "Ynl0ZSBhcnJheQ=="
}
```

### ResponseProofEvent


Perms: write

Inputs:
```json
[
{
"Id": "07070707-0707-0707-0707-070707070707",
"Payload": "Ynl0ZSBhcnJheQ==",
"Error": "string value"
}
]
```

Response: `{}`

22 changes: 22 additions & 0 deletions venus-shared/api/gateway/proxy_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions venus-shared/types/gateway/event.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package gateway

import (
"time"

"github.com/google/uuid"

"github.com/filecoin-project/go-address"
)

type ProofRegisterPolicy struct {
MinerAddress address.Address
}

type RequestEvent struct {
Id uuid.UUID
Method string
Payload []byte
CreateTime time.Time `json:"-"`
Result chan *ResponseEvent `json:"-"`
}

type ResponseEvent struct {
Id uuid.UUID
Payload []byte
Error string
}

0 comments on commit 6eacc83

Please sign in to comment.