Add debug: NewWithCustomRPCClient

This commit is contained in:
Slavomir 2021-07-06 22:31:39 +02:00
parent b6c09dc745
commit 85781927fb
1 changed files with 11 additions and 1 deletions

View File

@ -31,10 +31,14 @@ var ErrNotFound = errors.New("not found")
type Client struct {
rpcURL string
rpcClient jsonrpc.RPCClient
rpcClient CallForClientInterface
headers http.Header
}
type CallForClientInterface interface {
CallFor(out interface{}, method string, params ...interface{}) error
}
func NewClient(rpcURL string) *Client {
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) {
if c.headers == nil {
c.headers = http.Header{}