diff options
Diffstat (limited to 'internal')
-rw-r--r-- | internal/build/util.go | 16 | ||||
-rw-r--r-- | internal/ethapi/api.go | 29 | ||||
-rw-r--r-- | internal/jsre/pretty.go | 8 |
3 files changed, 17 insertions, 36 deletions
diff --git a/internal/build/util.go b/internal/build/util.go index 44f6760b9..ade9cbe93 100644 --- a/internal/build/util.go +++ b/internal/build/util.go @@ -138,6 +138,19 @@ func CopyFile(dst, src string, mode os.FileMode) { } } +// GoTool returns the command that runs a go tool. This uses go from GOROOT instead of PATH +// so that go commands executed by build use the same version of Go as the 'host' that runs +// build code. e.g. +// +// /usr/lib/go-1.8/bin/go run build/ci.go ... +// +// runs using go 1.8 and invokes go 1.8 tools from the same GOROOT. This is also important +// because runtime.Version checks on the host should match the tools that are run. +func GoTool(tool string, args ...string) *exec.Cmd { + args = append([]string{tool}, args...) + return exec.Command(filepath.Join(runtime.GOROOT(), "bin", "go"), args...) +} + // ExpandPackagesNoVendor expands a cmd/go import path pattern, skipping // vendored packages. func ExpandPackagesNoVendor(patterns []string) []string { @@ -148,8 +161,7 @@ func ExpandPackagesNoVendor(patterns []string) []string { } } if expand { - args := append([]string{"list"}, patterns...) - cmd := exec.Command(filepath.Join(runtime.GOROOT(), "bin", "go"), args...) + cmd := GoTool("list", patterns...) out, err := cmd.CombinedOutput() if err != nil { log.Fatalf("package listing failed: %v\n%s", err, string(out)) diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 1b23ac559..7874b7101 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -46,7 +46,6 @@ import ( const ( defaultGas = 90000 defaultGasPrice = 50 * params.Shannon - emptyHex = "0x" ) // PublicEthereumAPI provides an API to access Ethereum related information. @@ -548,26 +547,6 @@ func (s *PublicBlockChainAPI) GetStorageAt(ctx context.Context, address common.A return res[:], state.Error() } -// callmsg is the message type used for call transitions. -type callmsg struct { - addr common.Address - to *common.Address - gas, gasPrice *big.Int - value *big.Int - data []byte -} - -// accessor boilerplate to implement core.Message -func (m callmsg) From() (common.Address, error) { return m.addr, nil } -func (m callmsg) FromFrontier() (common.Address, error) { return m.addr, nil } -func (m callmsg) Nonce() uint64 { return 0 } -func (m callmsg) CheckNonce() bool { return false } -func (m callmsg) To() *common.Address { return m.to } -func (m callmsg) GasPrice() *big.Int { return m.gasPrice } -func (m callmsg) Gas() *big.Int { return m.gas } -func (m callmsg) Value() *big.Int { return m.value } -func (m callmsg) Data() []byte { return m.data } - // CallArgs represents the arguments for a call. type CallArgs struct { From common.Address `json:"from"` @@ -626,10 +605,8 @@ func (s *PublicBlockChainAPI) doCall(ctx context.Context, args CallArgs, blockNr // Wait for the context to be done and cancel the evm. Even if the // EVM has finished, cancelling may be done (repeatedly) go func() { - select { - case <-ctx.Done(): - evm.Cancel() - } + <-ctx.Done() + evm.Cancel() }() // Setup the gas pool (also for unmetered requests) @@ -1306,7 +1283,7 @@ func (api *PublicDebugAPI) PrintBlock(ctx context.Context, number uint64) (strin if block == nil { return "", fmt.Errorf("block #%d not found", number) } - return fmt.Sprintf("%s", block), nil + return block.String(), nil } // SeedHash retrieves the seed hash of a block. diff --git a/internal/jsre/pretty.go b/internal/jsre/pretty.go index e096eec23..16fa91b67 100644 --- a/internal/jsre/pretty.go +++ b/internal/jsre/pretty.go @@ -65,14 +65,6 @@ func prettyError(vm *otto.Otto, err error, w io.Writer) { fmt.Fprint(w, ErrorColor("%s", failure)) } -// jsErrorString adds a backtrace to errors generated by otto. -func jsErrorString(err error) string { - if ottoErr, ok := err.(*otto.Error); ok { - return ottoErr.String() - } - return err.Error() -} - func (re *JSRE) prettyPrintJS(call otto.FunctionCall) otto.Value { for _, v := range call.ArgumentList { prettyPrint(call.Otto, v, re.output) |