Add debug: NewWithCustomRPCClient
This commit is contained in:
parent
b6c09dc745
commit
85781927fb
|
@ -31,10 +31,14 @@ var ErrNotFound = errors.New("not found")
|
||||||
|
|
||||||
type Client struct {
|
type Client struct {
|
||||||
rpcURL string
|
rpcURL string
|
||||||
rpcClient jsonrpc.RPCClient
|
rpcClient CallForClientInterface
|
||||||
headers http.Header
|
headers http.Header
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type CallForClientInterface interface {
|
||||||
|
CallFor(out interface{}, method string, params ...interface{}) error
|
||||||
|
}
|
||||||
|
|
||||||
func NewClient(rpcURL string) *Client {
|
func NewClient(rpcURL string) *Client {
|
||||||
return NewClientWithOpts(rpcURL, nil)
|
return NewClientWithOpts(rpcURL, nil)
|
||||||
}
|
}
|
||||||
|
@ -47,6 +51,12 @@ func NewClientWithOpts(rpcURL string, opts *jsonrpc.RPCClientOpts) *Client {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewWithCustomRPCClient(rpcClient CallForClientInterface) *Client {
|
||||||
|
return &Client{
|
||||||
|
rpcClient: rpcClient,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Client) SetHeader(k, v string) {
|
func (c *Client) SetHeader(k, v string) {
|
||||||
if c.headers == nil {
|
if c.headers == nil {
|
||||||
c.headers = http.Header{}
|
c.headers = http.Header{}
|
||||||
|
|
Loading…
Reference in New Issue