aboutsummaryrefslogtreecommitdiffstats
path: root/internal/ethapi/api.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2016-06-15 06:36:31 +0800
committerFelix Lange <fjl@twurst.com>2016-08-17 23:39:04 +0800
commit1a9e66915b415cb1ca2bc2680f8fb4ff1883787c (patch)
tree849620e85ab94fccf1e49a9a2ea9602d700ea7c1 /internal/ethapi/api.go
parent84d11c19fd246e245906ca7e498a67f6e0c55e1e (diff)
downloadgo-tangerine-1a9e66915b415cb1ca2bc2680f8fb4ff1883787c.tar
go-tangerine-1a9e66915b415cb1ca2bc2680f8fb4ff1883787c.tar.gz
go-tangerine-1a9e66915b415cb1ca2bc2680f8fb4ff1883787c.tar.bz2
go-tangerine-1a9e66915b415cb1ca2bc2680f8fb4ff1883787c.tar.lz
go-tangerine-1a9e66915b415cb1ca2bc2680f8fb4ff1883787c.tar.xz
go-tangerine-1a9e66915b415cb1ca2bc2680f8fb4ff1883787c.tar.zst
go-tangerine-1a9e66915b415cb1ca2bc2680f8fb4ff1883787c.zip
common/compiler: simplify solc wrapper
Support for legacy version 0.9.x is gone. The compiler version is no longer cached. Compilation results (and the version) are read directly from stdout using the --combined-json flag. As a workaround for ethereum/solidity#651, source code is written to a temporary file before compilation. Integration of solc in package ethapi and cmd/abigen is now much simpler because the compiler wrapper is no longer passed around as a pointer. Fixes #2806, accidentally
Diffstat (limited to 'internal/ethapi/api.go')
-rw-r--r--internal/ethapi/api.go68
1 files changed, 3 insertions, 65 deletions
diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go
index 88bacc45b..ac9e2151d 100644
--- a/internal/ethapi/api.go
+++ b/internal/ethapi/api.go
@@ -20,7 +20,6 @@ import (
"bytes"
"encoding/hex"
"encoding/json"
- "errors"
"fmt"
"math/big"
"strings"
@@ -30,7 +29,6 @@ import (
"github.com/ethereum/ethash"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/common/compiler"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
@@ -50,14 +48,12 @@ const defaultGas = uint64(90000)
// PublicEthereumAPI provides an API to access Ethereum related information.
// It offers only methods that operate on public data that is freely available to anyone.
type PublicEthereumAPI struct {
- b Backend
- solcPath *string
- solc **compiler.Solidity
+ b Backend
}
// NewPublicEthereumAPI creates a new Etheruem protocol API.
-func NewPublicEthereumAPI(b Backend, solcPath *string, solc **compiler.Solidity) *PublicEthereumAPI {
- return &PublicEthereumAPI{b, solcPath, solc}
+func NewPublicEthereumAPI(b Backend) *PublicEthereumAPI {
+ return &PublicEthereumAPI{b}
}
// GasPrice returns a suggestion for a gas price.
@@ -65,39 +61,6 @@ func (s *PublicEthereumAPI) GasPrice(ctx context.Context) (*big.Int, error) {
return s.b.SuggestPrice(ctx)
}
-func (s *PublicEthereumAPI) getSolc() (*compiler.Solidity, error) {
- var err error
- solc := *s.solc
- if solc == nil {
- solc, err = compiler.New(*s.solcPath)
- }
- return solc, err
-}
-
-// GetCompilers returns the collection of available smart contract compilers
-func (s *PublicEthereumAPI) GetCompilers() ([]string, error) {
- solc, err := s.getSolc()
- if err == nil && solc != nil {
- return []string{"Solidity"}, nil
- }
-
- return []string{}, nil
-}
-
-// CompileSolidity compiles the given solidity source
-func (s *PublicEthereumAPI) CompileSolidity(source string) (map[string]*compiler.Contract, error) {
- solc, err := s.getSolc()
- if err != nil {
- return nil, err
- }
-
- if solc == nil {
- return nil, errors.New("solc (solidity compiler) not found")
- }
-
- return solc.Compile(source)
-}
-
// ProtocolVersion returns the current Ethereum protocol version this node supports
func (s *PublicEthereumAPI) ProtocolVersion() *rpc.HexNumber {
return rpc.NewHexNumber(s.b.ProtocolVersion())
@@ -1416,31 +1379,6 @@ func (s *PublicTransactionPoolAPI) Resend(ctx context.Context, tx *Tx, gasPrice,
return common.Hash{}, fmt.Errorf("Transaction %#x not found", tx.Hash)
}
-// PrivateAdminAPI is the collection of Etheruem APIs exposed over the private
-// admin endpoint.
-type PrivateAdminAPI struct {
- b Backend
- solcPath *string
- solc **compiler.Solidity
-}
-
-// NewPrivateAdminAPI creates a new API definition for the private admin methods
-// of the Ethereum service.
-func NewPrivateAdminAPI(b Backend, solcPath *string, solc **compiler.Solidity) *PrivateAdminAPI {
- return &PrivateAdminAPI{b, solcPath, solc}
-}
-
-// SetSolc sets the Solidity compiler path to be used by the node.
-func (api *PrivateAdminAPI) SetSolc(path string) (string, error) {
- var err error
- *api.solcPath = path
- *api.solc, err = compiler.New(path)
- if err != nil {
- return "", err
- }
- return (*api.solc).Info(), nil
-}
-
// PublicDebugAPI is the collection of Etheruem APIs exposed over the public
// debugging endpoint.
type PublicDebugAPI struct {