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:
Adrià Cidre 2018-05-04 16:14:19 +02:00 committed by GitHub
commit 2259b20eab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 19 deletions

View File

@ -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
View File

@ -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,
}
}