diff options
Diffstat (limited to 'eth/backend.go')
-rw-r--r-- | eth/backend.go | 52 |
1 files changed, 17 insertions, 35 deletions
diff --git a/eth/backend.go b/eth/backend.go index 351cc2744..c4a883c9e 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" @@ -71,7 +70,6 @@ type Config struct { Genesis string // Genesis JSON to seed the chain database with FastSync bool // Enables the state download based fast synchronisation algorithm - BlockChainVersion int SkipBcVersionCheck bool // e.g. blockchain export DatabaseCache int DatabaseHandles int @@ -83,11 +81,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 @@ -116,7 +113,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 @@ -132,7 +128,6 @@ type Ethereum struct { autodagquit chan bool etherbase common.Address solcPath string - solc *compiler.Solidity NatSpec bool PowTest bool @@ -143,7 +138,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 } @@ -158,9 +153,8 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { eth := &Ethereum{ chainDb: chainDb, - dappDb: dappDb, eventMux: ctx.EventMux, - accountManager: config.AccountManager, + accountManager: ctx.AccountManager, pow: pow, shutdownChan: make(chan bool), stopDbUpgrade: stopDbUpgrade, @@ -185,10 +179,10 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { if !config.SkipBcVersionCheck { bcVersion := core.GetBlockChainVersion(chainDb) - if bcVersion != config.BlockChainVersion && bcVersion != 0 { - return nil, fmt.Errorf("Blockchain DB version mismatch (%d / %d). Run geth upgradedb.\n", bcVersion, config.BlockChainVersion) + if bcVersion != core.BlockChainVersion && bcVersion != 0 { + return nil, fmt.Errorf("Blockchain DB version mismatch (%d / %d). Run geth upgradedb.\n", bcVersion, core.BlockChainVersion) } - core.WriteBlockChainVersion(chainDb, config.BlockChainVersion) + core.WriteBlockChainVersion(chainDb, core.BlockChainVersion) } // load the genesis block or write a new one if no genesis @@ -205,6 +199,8 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) { if config.ChainConfig == nil { return nil, errors.New("missing chain config") } + core.WriteChainConfig(chainDb, genesis.Hash(), config.ChainConfig) + eth.chainConfig = config.ChainConfig eth.chainConfig.VmConfig = vm.Config{ EnableJit: config.EnableJit, @@ -242,25 +238,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 @@ -304,7 +288,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", @@ -388,7 +372,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 } @@ -426,7 +409,6 @@ func (s *Ethereum) Stop() error { s.StopAutoDAG() s.chainDb.Close() - s.dappDb.Close() close(s.shutdownChan) return nil |