mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 09:53:48 +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"
|
||||
"net"
|
||||
"net/http"
|
||||
"runtime/debug"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/rs/cors"
|
||||
"github.com/ethereum/go-ethereum/log"
|
||||
"github.com/rs/cors"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
@ -71,7 +72,7 @@ func (hc *httpConn) Close() error {
|
|||
// using the provided HTTP Client.
|
||||
func DialHTTPWithClient(endpoint string, client *http.Client) (*Client, error) {
|
||||
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 {
|
||||
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 {
|
||||
hc := c.writeConn.(*httpConn)
|
||||
respBody, err := hc.doRequest(ctx, msg)
|
||||
log.Debug(fmt.Sprintf("Sending message %s",msg))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer respBody.Close()
|
||||
var respmsg jsonrpcMessage
|
||||
log.Debug(fmt.Sprintf("Got response %s",respmsg))
|
||||
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
|
||||
}
|
||||
op.resp <- &respmsg
|
||||
|
|
|
|||
Loading…
Reference in a new issue