From 312263c7d9457fe7c24aac8e42a4cf2efc6ccd8e Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Mon, 15 Aug 2016 18:38:32 +0200 Subject: cmd/utils, node: create account manager in package node The account manager was previously created by packge cmd/utils as part of flag processing and then passed down into eth.Ethereum through its config struct. Since we are starting to create nodes which do not have eth.Ethereum as a registered service, the code was rearranged to register the account manager as its own service. Making it a service is ugly though and it doesn't really fix the root cause: creating nodes without eth.Ethereum requires duplicating lots of code. This commit splits utils.MakeSystemNode into three functions, making creation of other node/service configurations easier. It also moves the account manager into Node so it can be used by those configurations without requiring package eth. --- eth/backend.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'eth') diff --git a/eth/backend.go b/eth/backend.go index c8a9af6ee..9b1ca306a 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -83,11 +83,10 @@ type Config struct { PowShared bool ExtraData []byte - AccountManager *accounts.Manager - Etherbase common.Address - GasPrice *big.Int - MinerThreads int - SolcPath string + Etherbase common.Address + GasPrice *big.Int + MinerThreads int + SolcPath string GpoMinGasPrice *big.Int GpoMaxGasPrice *big.Int @@ -160,7 +159,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { chainDb: chainDb, dappDb: dappDb, eventMux: ctx.EventMux, - accountManager: config.AccountManager, + accountManager: ctx.AccountManager, pow: pow, shutdownChan: make(chan bool), stopDbUpgrade: stopDbUpgrade, -- cgit From 84d11c19fd246e245906ca7e498a67f6e0c55e1e Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Wed, 15 Jun 2016 01:53:04 +0200 Subject: eth: remove dapp database remains --- eth/backend.go | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) (limited to 'eth') diff --git a/eth/backend.go b/eth/backend.go index 9b1ca306a..22388ddb5 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -115,7 +115,6 @@ type Ethereum struct { protocolManager *ProtocolManager // DB interfaces chainDb ethdb.Database // Block chain database - dappDb ethdb.Database // Dapp database eventMux *event.TypeMux pow *ethash.Ethash @@ -142,7 +141,7 @@ type Ethereum struct { // New creates a new Ethereum object (including the // initialisation of the common Ethereum object) func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { - chainDb, dappDb, err := CreateDBs(ctx, config) + chainDb, err := createDB(ctx, config) if err != nil { return nil, err } @@ -157,7 +156,6 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { eth := &Ethereum{ chainDb: chainDb, - dappDb: dappDb, eventMux: ctx.EventMux, accountManager: ctx.AccountManager, pow: pow, @@ -243,25 +241,13 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { return eth, nil } -// CreateDBs creates the chain and dapp databases for an Ethereum service -func CreateDBs(ctx *node.ServiceContext, config *Config) (chainDb, dappDb ethdb.Database, err error) { - // Open the chain database and perform any upgrades needed - chainDb, err = ctx.OpenDatabase("chaindata", config.DatabaseCache, config.DatabaseHandles) - if err != nil { - return nil, nil, err - } - if db, ok := chainDb.(*ethdb.LDBDatabase); ok { +// createDB creates the chain database. +func createDB(ctx *node.ServiceContext, config *Config) (ethdb.Database, error) { + db, err := ctx.OpenDatabase("chaindata", config.DatabaseCache, config.DatabaseHandles) + if db, ok := db.(*ethdb.LDBDatabase); ok { db.Meter("eth/db/chaindata/") } - - dappDb, err = ctx.OpenDatabase("dapp", config.DatabaseCache, config.DatabaseHandles) - if err != nil { - return nil, nil, err - } - if db, ok := dappDb.(*ethdb.LDBDatabase); ok { - db.Meter("eth/db/dapp/") - } - return + return db, err } // SetupGenesisBlock initializes the genesis block for an Ethereum service @@ -389,7 +375,6 @@ func (s *Ethereum) TxPool() *core.TxPool { return s.txPool } func (s *Ethereum) EventMux() *event.TypeMux { return s.eventMux } func (s *Ethereum) Pow() *ethash.Ethash { return s.pow } func (s *Ethereum) ChainDb() ethdb.Database { return s.chainDb } -func (s *Ethereum) DappDb() ethdb.Database { return s.dappDb } func (s *Ethereum) IsListening() bool { return true } // Always listening func (s *Ethereum) EthVersion() int { return int(s.protocolManager.SubProtocols[0].Version) } func (s *Ethereum) NetVersion() int { return s.netVersionId } @@ -427,7 +412,6 @@ func (s *Ethereum) Stop() error { s.StopAutoDAG() s.chainDb.Close() - s.dappDb.Close() close(s.shutdownChan) return nil -- cgit From 1a9e66915b415cb1ca2bc2680f8fb4ff1883787c Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Wed, 15 Jun 2016 00:36:31 +0200 Subject: 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 --- eth/backend.go | 4 +--- eth/bind.go | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'eth') diff --git a/eth/backend.go b/eth/backend.go index 22388ddb5..e1d123a02 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -31,7 +31,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/common/httpclient" "github.com/ethereum/go-ethereum/common/registrar/ethreg" "github.com/ethereum/go-ethereum/core" @@ -130,7 +129,6 @@ type Ethereum struct { autodagquit chan bool etherbase common.Address solcPath string - solc *compiler.Solidity NatSpec bool PowTest bool @@ -291,7 +289,7 @@ func CreatePoW(config *Config) (*ethash.Ethash, 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, &s.solc), []rpc.API{ + return append(ethapi.GetAPIs(s.apiBackend, s.solcPath), []rpc.API{ { Namespace: "eth", Version: "1.0", diff --git a/eth/bind.go b/eth/bind.go index c1366464f..bf7a7fb53 100644 --- a/eth/bind.go +++ b/eth/bind.go @@ -44,7 +44,7 @@ type ContractBackend struct { // Etheruem object. func NewContractBackend(eth *Ethereum) *ContractBackend { return &ContractBackend{ - eapi: ethapi.NewPublicEthereumAPI(eth.apiBackend, nil, nil), + eapi: ethapi.NewPublicEthereumAPI(eth.apiBackend), bcapi: ethapi.NewPublicBlockChainAPI(eth.apiBackend), txapi: ethapi.NewPublicTransactionPoolAPI(eth.apiBackend), } -- cgit