Merge pull request #9 from status-im/feature/inject-rpcclient
`New` receive an RPCClient and set it in the SDK instance
This commit is contained in:
commit
2259b20eab
17
rpcclient.go
17
rpcclient.go
|
@ -1,17 +0,0 @@
|
|||
package sdk
|
||||
|
||||
import "github.com/valyala/gorpc"
|
||||
|
||||
// RPCClient is a client to manage all rpc calls
|
||||
type RPCClient interface {
|
||||
Call(request interface{}) (response interface{}, err error)
|
||||
}
|
||||
|
||||
func newRPC(address string) RPCClient {
|
||||
rpc := &gorpc.Client{
|
||||
Addr: address, // "rpc.server.addr:12345",
|
||||
}
|
||||
rpc.Start()
|
||||
|
||||
return rpc
|
||||
}
|
9
sdk.go
9
sdk.go
|
@ -6,6 +6,11 @@ import (
|
|||
"log"
|
||||
)
|
||||
|
||||
// RPCClient is a client to manage all rpc calls
|
||||
type RPCClient interface {
|
||||
Call(request interface{}) (response interface{}, err error)
|
||||
}
|
||||
|
||||
// SDK is a set of tools to interact with status node
|
||||
type SDK struct {
|
||||
RPCClient RPCClient
|
||||
|
@ -18,9 +23,9 @@ type SDK struct {
|
|||
}
|
||||
|
||||
// New creates a default SDK object
|
||||
func New(address string) *SDK {
|
||||
func New(c RPCClient) *SDK {
|
||||
return &SDK{
|
||||
// RPCClient: newRPC(address),
|
||||
RPCClient: c,
|
||||
minimumPoW: 0.001,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue