internal/ethapi: drop eth_compile

This commit is contained in:
Julian Yap 2018-07-03 23:33:50 -10:00
parent f0992e40b2
commit 949fec0808
8 changed files with 4 additions and 113 deletions

View file

@ -139,7 +139,6 @@ func init() {
utils.EthStatsURLFlag, utils.EthStatsURLFlag,
utils.MetricsEnabledFlag, utils.MetricsEnabledFlag,
utils.FakePoWFlag, utils.FakePoWFlag,
utils.SolcPathFlag,
utils.GpoMinGasPriceFlag, utils.GpoMinGasPriceFlag,
utils.GpoMaxGasPriceFlag, utils.GpoMaxGasPriceFlag,
utils.GpoFullBlockRatioFlag, utils.GpoFullBlockRatioFlag,

View file

@ -172,12 +172,6 @@ var AppHelpFlagGroups = []flagGroup{
utils.WhisperEnabledFlag, utils.WhisperEnabledFlag,
}, },
}, },
{
Name: "MISCELLANEOUS",
Flags: []cli.Flag{
utils.SolcPathFlag,
},
},
} }
func init() { func init() {

View file

@ -376,11 +376,6 @@ var (
Usage: "JavaScript root path for `loadScript`", Usage: "JavaScript root path for `loadScript`",
Value: ".", Value: ".",
} }
SolcPathFlag = cli.StringFlag{
Name: "solc",
Usage: "Solidity compiler command to be used",
Value: "solc",
}
// Gas price oracle settings // Gas price oracle settings
GpoMinGasPriceFlag = cli.StringFlag{ GpoMinGasPriceFlag = cli.StringFlag{
@ -749,7 +744,6 @@ func RegisterEthService(ctx *cli.Context, stack *node.Node, extra []byte) {
GpobaseStepDown: ctx.GlobalInt(GpobaseStepDownFlag.Name), GpobaseStepDown: ctx.GlobalInt(GpobaseStepDownFlag.Name),
GpobaseStepUp: ctx.GlobalInt(GpobaseStepUpFlag.Name), GpobaseStepUp: ctx.GlobalInt(GpobaseStepUpFlag.Name),
GpobaseCorrectionFactor: ctx.GlobalInt(GpobaseCorrectionFactorFlag.Name), GpobaseCorrectionFactor: ctx.GlobalInt(GpobaseCorrectionFactorFlag.Name),
SolcPath: ctx.GlobalString(SolcPathFlag.Name),
AutoDAG: ctx.GlobalBool(AutoDAGFlag.Name) || ctx.GlobalBool(MiningEnabledFlag.Name), AutoDAG: ctx.GlobalBool(AutoDAGFlag.Name) || ctx.GlobalBool(MiningEnabledFlag.Name),
EnablePreimageRecording: ctx.GlobalBool(VMEnableDebugFlag.Name), EnablePreimageRecording: ctx.GlobalBool(VMEnableDebugFlag.Name),
} }

View file

@ -88,7 +88,6 @@ type Config struct {
Etherbase common.Address Etherbase common.Address
GasPrice *big.Int GasPrice *big.Int
MinerThreads int MinerThreads int
SolcPath string
GpoMinGasPrice *big.Int GpoMinGasPrice *big.Int
GpoMaxGasPrice *big.Int GpoMaxGasPrice *big.Int
@ -136,7 +135,6 @@ type Ethereum struct {
AutoDAG bool AutoDAG bool
autodagquit chan bool autodagquit chan bool
etherbase common.Address etherbase common.Address
solcPath string
netVersionId int netVersionId int
netRPCService *ethapi.PublicNetAPI netRPCService *ethapi.PublicNetAPI
@ -174,7 +172,6 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
etherbase: config.Etherbase, etherbase: config.Etherbase,
MinerThreads: config.MinerThreads, MinerThreads: config.MinerThreads,
AutoDAG: config.AutoDAG, AutoDAG: config.AutoDAG,
solcPath: config.SolcPath,
} }
if err := addMipmapBloomBins(chainDb); err != nil { if err := addMipmapBloomBins(chainDb); err != nil {
@ -305,7 +302,7 @@ func CreatePoW(config *Config) (pow.PoW, error) {
// APIs returns the collection of RPC services the ethereum package offers. // APIs returns the collection of RPC services the ethereum package offers.
// NOTE, some of these services probably need to be moved to somewhere else. // NOTE, some of these services probably need to be moved to somewhere else.
func (s *Ethereum) APIs() []rpc.API { func (s *Ethereum) APIs() []rpc.API {
return append(ethapi.GetAPIs(s.ApiBackend, s.solcPath), []rpc.API{ return append(ethapi.GetAPIs(s.ApiBackend), []rpc.API{
{ {
Namespace: "eth", Namespace: "eth",
Version: "1.0", Version: "1.0",

View file

@ -72,9 +72,8 @@ type State interface {
GetNonce(ctx context.Context, addr common.Address) (uint64, error) GetNonce(ctx context.Context, addr common.Address) (uint64, error)
} }
func GetAPIs(apiBackend Backend, solcPath string) []rpc.API { func GetAPIs(apiBackend Backend) []rpc.API {
compiler := makeCompilerAPIs(solcPath) return []rpc.API{
all := []rpc.API{
{ {
Namespace: "eth", Namespace: "eth",
Version: "1.0", Version: "1.0",
@ -116,5 +115,4 @@ func GetAPIs(apiBackend Backend, solcPath string) []rpc.API {
Public: false, Public: false,
}, },
} }
return append(compiler, all...)
} }

View file

@ -1,82 +0,0 @@
// Copyright 2016 The go-ethereum Authors
// This file is part of the go-ethereum library.
//
// The go-ethereum library is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// The go-ethereum library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
package ethapi
import (
"sync"
"github.com/ubiq/go-ubiq/common/compiler"
"github.com/ubiq/go-ubiq/rpc"
)
func makeCompilerAPIs(solcPath string) []rpc.API {
c := &compilerAPI{solc: solcPath}
return []rpc.API{
{
Namespace: "eth",
Version: "1.0",
Service: (*PublicCompilerAPI)(c),
Public: true,
},
{
Namespace: "admin",
Version: "1.0",
Service: (*CompilerAdminAPI)(c),
Public: true,
},
}
}
type compilerAPI struct {
// This lock guards the solc path set through the API.
// It also ensures that only one solc process is used at
// any time.
mu sync.Mutex
solc string
}
type CompilerAdminAPI compilerAPI
// SetSolc sets the Solidity compiler path to be used by the node.
func (api *CompilerAdminAPI) SetSolc(path string) (string, error) {
api.mu.Lock()
defer api.mu.Unlock()
info, err := compiler.SolidityVersion(path)
if err != nil {
return "", err
}
api.solc = path
return info.FullVersion, nil
}
type PublicCompilerAPI compilerAPI
// CompileSolidity compiles the given solidity source.
func (api *PublicCompilerAPI) CompileSolidity(source string) (map[string]*compiler.Contract, error) {
api.mu.Lock()
defer api.mu.Unlock()
return compiler.CompileSolidityString(api.solc, source)
}
func (api *PublicCompilerAPI) GetCompilers() ([]string, error) {
api.mu.Lock()
defer api.mu.Unlock()
if _, err := compiler.SolidityVersion(api.solc); err == nil {
return []string{"Solidity"}, nil
}
return []string{}, nil
}

View file

@ -93,11 +93,6 @@ web3._extend({
call: 'admin_sleepBlocks', call: 'admin_sleepBlocks',
params: 2 params: 2
}), }),
new web3._extend.Method({
name: 'setSolc',
call: 'admin_setSolc',
params: 1
}),
new web3._extend.Method({ new web3._extend.Method({
name: 'startRPC', name: 'startRPC',
call: 'admin_startRPC', call: 'admin_startRPC',

View file

@ -24,7 +24,6 @@ import (
"github.com/ubiq/go-ubiq/accounts" "github.com/ubiq/go-ubiq/accounts"
"github.com/ubiq/go-ubiq/common" "github.com/ubiq/go-ubiq/common"
"github.com/ubiq/go-ubiq/common/compiler"
"github.com/ubiq/go-ubiq/common/hexutil" "github.com/ubiq/go-ubiq/common/hexutil"
"github.com/ubiq/go-ubiq/core" "github.com/ubiq/go-ubiq/core"
"github.com/ubiq/go-ubiq/core/types" "github.com/ubiq/go-ubiq/core/types"
@ -63,8 +62,6 @@ type LightEthereum struct {
eventMux *event.TypeMux eventMux *event.TypeMux
pow pow.PoW pow pow.PoW
accountManager *accounts.Manager accountManager *accounts.Manager
solcPath string
solc *compiler.Solidity
netVersionId int netVersionId int
netRPCService *ethapi.PublicNetAPI netRPCService *ethapi.PublicNetAPI
@ -94,7 +91,6 @@ func New(ctx *node.ServiceContext, config *eth.Config) (*LightEthereum, error) {
pow: pow, pow: pow,
shutdownChan: make(chan bool), shutdownChan: make(chan bool),
netVersionId: config.NetworkId, netVersionId: config.NetworkId,
solcPath: config.SolcPath,
} }
if config.ChainConfig == nil { if config.ChainConfig == nil {
@ -144,7 +140,7 @@ func (s *LightDummyAPI) Mining() bool {
// APIs returns the collection of RPC services the ethereum package offers. // APIs returns the collection of RPC services the ethereum package offers.
// NOTE, some of these services probably need to be moved to somewhere else. // NOTE, some of these services probably need to be moved to somewhere else.
func (s *LightEthereum) APIs() []rpc.API { func (s *LightEthereum) APIs() []rpc.API {
return append(ethapi.GetAPIs(s.ApiBackend, s.solcPath), []rpc.API{ return append(ethapi.GetAPIs(s.ApiBackend), []rpc.API{
{ {
Namespace: "eth", Namespace: "eth",
Version: "1.0", Version: "1.0",