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

@ -9,4 +9,4 @@ func NewRPC(addr string) api.API {
var res api.Struct
rpclib.NewClient(addr, "Filecoin", &res.Internal)
return &res
}
}

View File

@ -7,8 +7,8 @@ import (
)
type Struct struct {
Internal struct{
ID func(context.Context) (peer.ID, error)
Internal struct {
ID func(context.Context) (peer.ID, error)
Version func(context.Context) (Version, error)
}
}
@ -21,4 +21,4 @@ func (c *Struct) Version(ctx context.Context) (Version, error) {
return c.Internal.Version(ctx)
}
var _ API = &Struct{}
var _ API = &Struct{}

View File

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

View File

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

View File

@ -8,6 +8,6 @@ import (
// RecordValidator provides namesys compatible routing record validator
func RecordValidator(ps peerstore.Peerstore) record.Validator {
return record.NamespacedValidator{
"pk": record.PublicKeyValidator{},
"pk": record.PublicKeyValidator{},
}
}

View File

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

View File

@ -60,4 +60,4 @@ func PNetChecker(repo repo.Repo, ph host.Host, lc fx.Lifecycle) error {
})
return nil
}
*/
*/

View File

@ -19,4 +19,4 @@ func RandomPeerID() (peer.ID, error) {
return "", err
}
return peer.ID(hash), nil
}
}

View File

@ -12,7 +12,7 @@ import (
)
var (
errorType = reflect.TypeOf(new(error)).Elem()
errorType = reflect.TypeOf(new(error)).Elem()
contextType = reflect.TypeOf(new(context.Context)).Elem()
)
@ -80,7 +80,7 @@ func NewClient(addr string, namespace string, handler interface{}) {
return out
}
processError := func(err error) []reflect.Value{
processError := func(err error) []reflect.Value {
out := make([]reflect.Value, nout)
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) {
id := atomic.AddInt64(&idCtr, 1)
params := make([]param, len(args) - hasCtx)
params := make([]param, len(args)-hasCtx)
for i, arg := range args[hasCtx:] {
params[i] = param{
v: arg,

View File

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

View File

@ -167,7 +167,7 @@ func TestRPC(t *testing.T) {
type CtxHandler struct {
cancelled bool
i int
i int
}
func (h *CtxHandler) Test(ctx context.Context) {
@ -200,7 +200,7 @@ func TestCtx(t *testing.T) {
}
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()
client.Test(ctx)
@ -219,4 +219,4 @@ func TestCtx(t *testing.T) {
if serverHandler.cancelled || serverHandler.i != 2 {
t.Error("wrong serverHandler state")
}
}
}