lotus/api/client/client.go

44 lines
1.2 KiB
Go
Raw Normal View History

package client
import (
2019-07-23 18:49:09 +00:00
"net/http"
"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/lib/jsonrpc"
)
2019-08-02 16:25:10 +00:00
// NewCommonRPC creates a new http jsonrpc client.
2019-10-03 18:12:30 +00:00
func NewCommonRPC(addr string, requestHeader http.Header) (api.Common, jsonrpc.ClientCloser, error) {
2019-08-02 16:25:10 +00:00
var res api.CommonStruct
2019-10-03 18:12:30 +00:00
closer, err := jsonrpc.NewMergeClient(addr, "Filecoin",
2019-08-02 16:25:10 +00:00
[]interface{}{
&res.Internal,
}, requestHeader)
2019-10-03 18:12:30 +00:00
return &res, closer, err
2019-08-02 16:25:10 +00:00
}
// NewFullNodeRPC creates a new http jsonrpc client.
2019-10-03 18:12:30 +00:00
func NewFullNodeRPC(addr string, requestHeader http.Header) (api.FullNode, jsonrpc.ClientCloser, error) {
2019-07-24 00:09:34 +00:00
var res api.FullNodeStruct
2019-10-03 18:12:30 +00:00
closer, err := jsonrpc.NewMergeClient(addr, "Filecoin",
[]interface{}{
&res.CommonStruct.Internal,
&res.Internal,
}, requestHeader)
2019-10-03 18:12:30 +00:00
return &res, closer, err
}
// NewStorageMinerRPC creates a new http jsonrpc client for storage miner
2019-10-03 18:12:30 +00:00
func NewStorageMinerRPC(addr string, requestHeader http.Header) (api.StorageMiner, jsonrpc.ClientCloser, error) {
var res api.StorageMinerStruct
2019-10-03 18:12:30 +00:00
closer, err := jsonrpc.NewMergeClient(addr, "Filecoin",
[]interface{}{
&res.CommonStruct.Internal,
&res.Internal,
}, requestHeader)
2019-10-03 18:12:30 +00:00
return &res, closer, err
2019-07-24 01:10:26 +00:00
}