mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 09:53:48 +00:00
Merge b4a5f49cbc into ec3db0f56c
This commit is contained in:
commit
fb9b992500
3 changed files with 9 additions and 4 deletions
|
|
@ -95,7 +95,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)
|
||||||
|
|
||||||
|
|
@ -143,7 +143,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 +196,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)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -133,7 +133,7 @@ func (c *Console) init(preload []string) error {
|
||||||
// Load the supported APIs into the JavaScript runtime environment
|
// Load the supported APIs into the JavaScript runtime environment
|
||||||
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 {
|
||||||
|
|
|
||||||
|
|
@ -27,10 +27,12 @@ import (
|
||||||
"mime"
|
"mime"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"runtime/debug"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/log"
|
||||||
"github.com/rs/cors"
|
"github.com/rs/cors"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -70,6 +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))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
@ -96,6 +99,8 @@ func (c *Client) sendHTTP(ctx context.Context, op *requestOp, msg interface{}) e
|
||||||
defer respBody.Close()
|
defer respBody.Close()
|
||||||
var respmsg jsonrpcMessage
|
var respmsg jsonrpcMessage
|
||||||
if err := json.NewDecoder(respBody).Decode(&respmsg); err != nil {
|
if err := json.NewDecoder(respBody).Decode(&respmsg); err != nil {
|
||||||
|
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