mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 02:12:23 +00:00
internal/ethapi: drop eth_compile
This commit is contained in:
parent
f0992e40b2
commit
949fec0808
8 changed files with 4 additions and 113 deletions
|
|
@ -139,7 +139,6 @@ func init() {
|
|||
utils.EthStatsURLFlag,
|
||||
utils.MetricsEnabledFlag,
|
||||
utils.FakePoWFlag,
|
||||
utils.SolcPathFlag,
|
||||
utils.GpoMinGasPriceFlag,
|
||||
utils.GpoMaxGasPriceFlag,
|
||||
utils.GpoFullBlockRatioFlag,
|
||||
|
|
|
|||
|
|
@ -172,12 +172,6 @@ var AppHelpFlagGroups = []flagGroup{
|
|||
utils.WhisperEnabledFlag,
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "MISCELLANEOUS",
|
||||
Flags: []cli.Flag{
|
||||
utils.SolcPathFlag,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
|
|
|||
|
|
@ -376,11 +376,6 @@ var (
|
|||
Usage: "JavaScript root path for `loadScript`",
|
||||
Value: ".",
|
||||
}
|
||||
SolcPathFlag = cli.StringFlag{
|
||||
Name: "solc",
|
||||
Usage: "Solidity compiler command to be used",
|
||||
Value: "solc",
|
||||
}
|
||||
|
||||
// Gas price oracle settings
|
||||
GpoMinGasPriceFlag = cli.StringFlag{
|
||||
|
|
@ -749,7 +744,6 @@ func RegisterEthService(ctx *cli.Context, stack *node.Node, extra []byte) {
|
|||
GpobaseStepDown: ctx.GlobalInt(GpobaseStepDownFlag.Name),
|
||||
GpobaseStepUp: ctx.GlobalInt(GpobaseStepUpFlag.Name),
|
||||
GpobaseCorrectionFactor: ctx.GlobalInt(GpobaseCorrectionFactorFlag.Name),
|
||||
SolcPath: ctx.GlobalString(SolcPathFlag.Name),
|
||||
AutoDAG: ctx.GlobalBool(AutoDAGFlag.Name) || ctx.GlobalBool(MiningEnabledFlag.Name),
|
||||
EnablePreimageRecording: ctx.GlobalBool(VMEnableDebugFlag.Name),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,7 +88,6 @@ type Config struct {
|
|||
Etherbase common.Address
|
||||
GasPrice *big.Int
|
||||
MinerThreads int
|
||||
SolcPath string
|
||||
|
||||
GpoMinGasPrice *big.Int
|
||||
GpoMaxGasPrice *big.Int
|
||||
|
|
@ -136,7 +135,6 @@ type Ethereum struct {
|
|||
AutoDAG bool
|
||||
autodagquit chan bool
|
||||
etherbase common.Address
|
||||
solcPath string
|
||||
|
||||
netVersionId int
|
||||
netRPCService *ethapi.PublicNetAPI
|
||||
|
|
@ -174,7 +172,6 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
|
|||
etherbase: config.Etherbase,
|
||||
MinerThreads: config.MinerThreads,
|
||||
AutoDAG: config.AutoDAG,
|
||||
solcPath: config.SolcPath,
|
||||
}
|
||||
|
||||
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.
|
||||
// NOTE, some of these services probably need to be moved to somewhere else.
|
||||
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",
|
||||
Version: "1.0",
|
||||
|
|
|
|||
|
|
@ -72,9 +72,8 @@ type State interface {
|
|||
GetNonce(ctx context.Context, addr common.Address) (uint64, error)
|
||||
}
|
||||
|
||||
func GetAPIs(apiBackend Backend, solcPath string) []rpc.API {
|
||||
compiler := makeCompilerAPIs(solcPath)
|
||||
all := []rpc.API{
|
||||
func GetAPIs(apiBackend Backend) []rpc.API {
|
||||
return []rpc.API{
|
||||
{
|
||||
Namespace: "eth",
|
||||
Version: "1.0",
|
||||
|
|
@ -116,5 +115,4 @@ func GetAPIs(apiBackend Backend, solcPath string) []rpc.API {
|
|||
Public: false,
|
||||
},
|
||||
}
|
||||
return append(compiler, all...)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
@ -93,11 +93,6 @@ web3._extend({
|
|||
call: 'admin_sleepBlocks',
|
||||
params: 2
|
||||
}),
|
||||
new web3._extend.Method({
|
||||
name: 'setSolc',
|
||||
call: 'admin_setSolc',
|
||||
params: 1
|
||||
}),
|
||||
new web3._extend.Method({
|
||||
name: 'startRPC',
|
||||
call: 'admin_startRPC',
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ import (
|
|||
|
||||
"github.com/ubiq/go-ubiq/accounts"
|
||||
"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/core"
|
||||
"github.com/ubiq/go-ubiq/core/types"
|
||||
|
|
@ -63,8 +62,6 @@ type LightEthereum struct {
|
|||
eventMux *event.TypeMux
|
||||
pow pow.PoW
|
||||
accountManager *accounts.Manager
|
||||
solcPath string
|
||||
solc *compiler.Solidity
|
||||
|
||||
netVersionId int
|
||||
netRPCService *ethapi.PublicNetAPI
|
||||
|
|
@ -94,7 +91,6 @@ func New(ctx *node.ServiceContext, config *eth.Config) (*LightEthereum, error) {
|
|||
pow: pow,
|
||||
shutdownChan: make(chan bool),
|
||||
netVersionId: config.NetworkId,
|
||||
solcPath: config.SolcPath,
|
||||
}
|
||||
|
||||
if config.ChainConfig == nil {
|
||||
|
|
@ -144,7 +140,7 @@ func (s *LightDummyAPI) Mining() bool {
|
|||
// APIs returns the collection of RPC services the ethereum package offers.
|
||||
// NOTE, some of these services probably need to be moved to somewhere else.
|
||||
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",
|
||||
Version: "1.0",
|
||||
|
|
|
|||
Loading…
Reference in a new issue