License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
This commit is contained in:
Jakub Sztandera 2019-07-01 22:00:22 +02:00
parent 088c1e7860
commit 5736ac1d9d
11 changed files with 15 additions and 17 deletions

View File

@ -7,7 +7,7 @@ import (
) )
type Struct struct { type Struct struct {
Internal struct{ Internal struct {
ID func(context.Context) (peer.ID, error) ID func(context.Context) (peer.ID, error)
Version func(context.Context) (Version, error) Version func(context.Context) (Version, error)
} }

View File

@ -7,7 +7,6 @@ import (
"github.com/filecoin-project/go-lotus/rpclib" "github.com/filecoin-project/go-lotus/rpclib"
) )
func serveRPC(api api.API) error { func serveRPC(api api.API) error {
rpcServer := rpclib.NewServer() rpcServer := rpclib.NewServer()
rpcServer.Register("Filecoin", api) rpcServer.Register("Filecoin", api)

View File

@ -57,7 +57,7 @@ func New(ctx context.Context) (api.API, error) {
libp2p.Routing, libp2p.Routing,
libp2p.NatPortMap, libp2p.NatPortMap,
libp2p.ConnectionManager(50, 200, 20 * time.Second), libp2p.ConnectionManager(50, 200, 20*time.Second),
), ),
fx.Invoke( fx.Invoke(

View File

@ -22,4 +22,3 @@ func LifecycleCtx(mctx MetricsCtx, lc fx.Lifecycle) context.Context {
}) })
return ctx return ctx
} }

View File

@ -80,7 +80,7 @@ func NewClient(addr string, namespace string, handler interface{}) {
return out return out
} }
processError := func(err error) []reflect.Value{ processError := func(err error) []reflect.Value {
out := make([]reflect.Value, nout) out := make([]reflect.Value, nout)
if valOut != -1 { if valOut != -1 {
@ -101,7 +101,7 @@ func NewClient(addr string, namespace string, handler interface{}) {
fn := reflect.MakeFunc(ftyp, func(args []reflect.Value) (results []reflect.Value) { fn := reflect.MakeFunc(ftyp, func(args []reflect.Value) (results []reflect.Value) {
id := atomic.AddInt64(&idCtr, 1) id := atomic.AddInt64(&idCtr, 1)
params := make([]param, len(args) - hasCtx) params := make([]param, len(args)-hasCtx)
for i, arg := range args[hasCtx:] { for i, arg := range args[hasCtx:] {
params[i] = param{ params[i] = param{
v: arg, v: arg,

View File

@ -151,7 +151,7 @@ func (s *RPCServer) Register(namespace string, r interface{}) {
valOut, errOut, _ := processFuncOut(funcType) valOut, errOut, _ := processFuncOut(funcType)
fmt.Println(namespace+"."+method.Name) fmt.Println(namespace + "." + method.Name)
s.methods[namespace+"."+method.Name] = rpcHandler{ s.methods[namespace+"."+method.Name] = rpcHandler{
paramReceivers: recvs, paramReceivers: recvs,

View File

@ -200,7 +200,7 @@ func TestCtx(t *testing.T) {
} }
NewClient(testServ.URL, "CtxHandler", &client) NewClient(testServ.URL, "CtxHandler", &client)
ctx, cancel := context.WithTimeout(context.Background(), 20 * time.Millisecond) ctx, cancel := context.WithTimeout(context.Background(), 20*time.Millisecond)
defer cancel() defer cancel()
client.Test(ctx) client.Test(ctx)