2019-06-25 11:42:17 +00:00
|
|
|
package client
|
|
|
|
|
|
|
|
import (
|
2019-07-23 18:49:09 +00:00
|
|
|
"net/http"
|
|
|
|
|
2019-06-25 11:42:17 +00:00
|
|
|
"github.com/filecoin-project/go-lotus/api"
|
2019-07-08 12:46:30 +00:00
|
|
|
"github.com/filecoin-project/go-lotus/lib/jsonrpc"
|
2019-06-25 11:42:17 +00:00
|
|
|
)
|
|
|
|
|
2019-07-24 00:40:19 +00:00
|
|
|
// NewFullNodeRPC creates a new http jsonrpc client.
|
|
|
|
func NewFullNodeRPC(addr string, requestHeader http.Header) (api.FullNode, error) {
|
2019-07-24 00:09:34 +00:00
|
|
|
var res api.FullNodeStruct
|
2019-07-24 00:40:19 +00:00
|
|
|
_, err := jsonrpc.NewMergeClient(addr, "Filecoin",
|
|
|
|
[]interface{}{
|
|
|
|
&res.CommonStruct.Internal,
|
|
|
|
&res.Internal,
|
|
|
|
}, requestHeader)
|
|
|
|
|
2019-07-12 15:29:41 +00:00
|
|
|
return &res, err
|
2019-07-01 20:00:22 +00:00
|
|
|
}
|
2019-07-24 00:40:19 +00:00
|
|
|
|
|
|
|
// NewStorageMinerRPC creates a new http jsonrpc client for storage miner
|
|
|
|
func NewStorageMinerRPC(addr string, requestHeader http.Header) (api.StorageMiner, error) {
|
|
|
|
var res api.StorageMinerStruct
|
|
|
|
_, err := jsonrpc.NewMergeClient(addr, "Filecoin",
|
|
|
|
[]interface{}{
|
|
|
|
&res.CommonStruct.Internal,
|
|
|
|
&res.Internal,
|
|
|
|
}, requestHeader)
|
|
|
|
|
|
|
|
return &res, err
|
2019-07-24 01:10:26 +00:00
|
|
|
}
|