helpful logging and gofmt!

This commit is contained in:
Lee Azzarello 2018-04-12 17:06:30 -07:00
parent fc240d64a6
commit 3ff2ba9ae9

View file

@ -27,12 +27,13 @@ import (
"mime" "mime"
"net" "net"
"net/http" "net/http"
"runtime/debug"
"strings" "strings"
"sync" "sync"
"time" "time"
"github.com/rs/cors"
"github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/log"
"github.com/rs/cors"
) )
const ( const (
@ -92,15 +93,14 @@ func DialHTTP(endpoint string) (*Client, error) {
func (c *Client) sendHTTP(ctx context.Context, op *requestOp, msg interface{}) error { func (c *Client) sendHTTP(ctx context.Context, op *requestOp, msg interface{}) error {
hc := c.writeConn.(*httpConn) hc := c.writeConn.(*httpConn)
respBody, err := hc.doRequest(ctx, msg) respBody, err := hc.doRequest(ctx, msg)
log.Debug(fmt.Sprintf("Sending message %s",msg))
if err != nil { if err != nil {
return err return err
} }
defer respBody.Close() defer respBody.Close()
var respmsg jsonrpcMessage var respmsg jsonrpcMessage
log.Debug(fmt.Sprintf("Got response %s",respmsg))
if err := json.NewDecoder(respBody).Decode(&respmsg); err != nil { if err := json.NewDecoder(respBody).Decode(&respmsg); err != nil {
log.Debug(fmt.Sprintf("Error decoding JSON response: %s", err)) err := fmt.Errorf("Error creating HTTP connection to RPC socket. Did you set --rpcvhosts on the server? Actual error is \"%s\"", err)
debug.PrintStack()
return err return err
} }
op.resp <- &respmsg op.resp <- &respmsg