mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 18:02:24 +00:00
added debugging output for JSON error
This commit is contained in:
parent
3ebcf92b42
commit
fc240d64a6
4 changed files with 13 additions and 4 deletions
|
|
@ -28,6 +28,7 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/console"
|
"github.com/ethereum/go-ethereum/console"
|
||||||
"github.com/ethereum/go-ethereum/node"
|
"github.com/ethereum/go-ethereum/node"
|
||||||
"github.com/ethereum/go-ethereum/rpc"
|
"github.com/ethereum/go-ethereum/rpc"
|
||||||
|
"github.com/ethereum/go-ethereum/log"
|
||||||
"gopkg.in/urfave/cli.v1"
|
"gopkg.in/urfave/cli.v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -95,7 +96,7 @@ func localConsole(ctx *cli.Context) error {
|
||||||
|
|
||||||
console, err := console.New(config)
|
console, err := console.New(config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.Fatalf("Failed to start the JavaScript console: %v", err)
|
utils.Fatalf("Failed to start the local JavaScript console: %v", err)
|
||||||
}
|
}
|
||||||
defer console.Stop(false)
|
defer console.Stop(false)
|
||||||
|
|
||||||
|
|
@ -116,6 +117,7 @@ func localConsole(ctx *cli.Context) error {
|
||||||
func remoteConsole(ctx *cli.Context) error {
|
func remoteConsole(ctx *cli.Context) error {
|
||||||
// Attach to a remotely running geth instance and start the JavaScript console
|
// Attach to a remotely running geth instance and start the JavaScript console
|
||||||
endpoint := ctx.Args().First()
|
endpoint := ctx.Args().First()
|
||||||
|
log.Debug(fmt.Sprintf("remote endpoint is %s", endpoint))
|
||||||
if endpoint == "" {
|
if endpoint == "" {
|
||||||
path := node.DefaultDataDir()
|
path := node.DefaultDataDir()
|
||||||
if ctx.GlobalIsSet(utils.DataDirFlag.Name) {
|
if ctx.GlobalIsSet(utils.DataDirFlag.Name) {
|
||||||
|
|
@ -143,7 +145,7 @@ func remoteConsole(ctx *cli.Context) error {
|
||||||
|
|
||||||
console, err := console.New(config)
|
console, err := console.New(config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.Fatalf("Failed to start the JavaScript console: %v", err)
|
utils.Fatalf("Failed to start the remote JavaScript console: %v", err)
|
||||||
}
|
}
|
||||||
defer console.Stop(false)
|
defer console.Stop(false)
|
||||||
|
|
||||||
|
|
@ -196,7 +198,7 @@ func ephemeralConsole(ctx *cli.Context) error {
|
||||||
|
|
||||||
console, err := console.New(config)
|
console, err := console.New(config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.Fatalf("Failed to start the JavaScript console: %v", err)
|
utils.Fatalf("Failed to start the ephemeral JavaScript console: %v", err)
|
||||||
}
|
}
|
||||||
defer console.Stop(false)
|
defer console.Stop(false)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -131,9 +131,10 @@ func (c *Console) init(preload []string) error {
|
||||||
return fmt.Errorf("web3 provider: %v", err)
|
return fmt.Errorf("web3 provider: %v", err)
|
||||||
}
|
}
|
||||||
// Load the supported APIs into the JavaScript runtime environment
|
// Load the supported APIs into the JavaScript runtime environment
|
||||||
|
// This is where the Zeroconf DNS bails
|
||||||
apis, err := c.client.SupportedModules()
|
apis, err := c.client.SupportedModules()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("api modules: %v", err)
|
return fmt.Errorf("cannot create api client modules: %v", err)
|
||||||
}
|
}
|
||||||
flatten := "var eth = web3.eth; var personal = web3.personal; "
|
flatten := "var eth = web3.eth; var personal = web3.personal; "
|
||||||
for api := range apis {
|
for api := range apis {
|
||||||
|
|
|
||||||
|
|
@ -168,6 +168,7 @@ func DialContext(ctx context.Context, rawurl string) (*Client, error) {
|
||||||
}
|
}
|
||||||
switch u.Scheme {
|
switch u.Scheme {
|
||||||
case "http", "https":
|
case "http", "https":
|
||||||
|
log.Debug(fmt.Sprintf("connecting to rpc url %s", rawurl))
|
||||||
return DialHTTP(rawurl)
|
return DialHTTP(rawurl)
|
||||||
case "ws", "wss":
|
case "ws", "wss":
|
||||||
return DialWebsocket(ctx, rawurl, "")
|
return DialWebsocket(ctx, rawurl, "")
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/rs/cors"
|
"github.com/rs/cors"
|
||||||
|
"github.com/ethereum/go-ethereum/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
@ -70,6 +71,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))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -90,12 +92,15 @@ 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))
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
op.resp <- &respmsg
|
op.resp <- &respmsg
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue