mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 01:43:47 +00:00
helpful logging and gofmt!
This commit is contained in:
parent
fc240d64a6
commit
3ff2ba9ae9
1 changed files with 5 additions and 5 deletions
10
rpc/http.go
10
rpc/http.go
|
|
@ -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 (
|
||||||
|
|
@ -71,7 +72,7 @@ func (hc *httpConn) Close() error {
|
||||||
// using the provided HTTP Client.
|
// using the provided HTTP Client.
|
||||||
func DialHTTPWithClient(endpoint string, client *http.Client) (*Client, error) {
|
func DialHTTPWithClient(endpoint string, client *http.Client) (*Client, error) {
|
||||||
req, err := http.NewRequest(http.MethodPost, endpoint, nil)
|
req, err := http.NewRequest(http.MethodPost, endpoint, nil)
|
||||||
log.Debug(fmt.Sprintf("connecting to HTTP endpoint %s", endpoint))
|
log.Debug(fmt.Sprintf("connecting to HTTP endpoint %s", endpoint))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue