aboutsummaryrefslogtreecommitdiffstats
path: root/eth/backend.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2018-05-07 19:35:06 +0800
committerGitHub <noreply@github.com>2018-05-07 19:35:06 +0800
commit6cf0ab38bd0af77d81aad4c104979cebee9e3e63 (patch)
tree142d6f965c44dcf9e2182da67b7bbc978c573448 /eth/backend.go
parent5463ed99968bf71685a2a8ee9dbf8705912f00cb (diff)
downloaddexon-6cf0ab38bd0af77d81aad4c104979cebee9e3e63.tar
dexon-6cf0ab38bd0af77d81aad4c104979cebee9e3e63.tar.gz
dexon-6cf0ab38bd0af77d81aad4c104979cebee9e3e63.tar.bz2
dexon-6cf0ab38bd0af77d81aad4c104979cebee9e3e63.tar.lz
dexon-6cf0ab38bd0af77d81aad4c104979cebee9e3e63.tar.xz
dexon-6cf0ab38bd0af77d81aad4c104979cebee9e3e63.tar.zst
dexon-6cf0ab38bd0af77d81aad4c104979cebee9e3e63.zip
core/rawdb: separate raw database access to own package (#16666)
Diffstat (limited to 'eth/backend.go')
-rw-r--r--eth/backend.go15
1 files changed, 5 insertions, 10 deletions
diff --git a/eth/backend.go b/eth/backend.go
index a26ccd044..e4c5fef3e 100644
--- a/eth/backend.go
+++ b/eth/backend.go
@@ -33,6 +33,7 @@ import (
"github.com/ethereum/go-ethereum/consensus/ethash"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/bloombits"
+ "github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/eth/downloader"
@@ -63,8 +64,7 @@ type Ethereum struct {
chainConfig *params.ChainConfig
// Channel for shutting down the service
- shutdownChan chan bool // Channel for shutting down the Ethereum
- stopDbUpgrade func() error // stop chain db sequential key upgrade
+ shutdownChan chan bool // Channel for shutting down the Ethereum
// Handlers
txPool *core.TxPool
@@ -112,7 +112,6 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
if err != nil {
return nil, err
}
- stopDbUpgrade := upgradeDeduplicateData(chainDb)
chainConfig, genesisHash, genesisErr := core.SetupGenesisBlock(chainDb, config.Genesis)
if _, ok := genesisErr.(*params.ConfigCompatError); genesisErr != nil && !ok {
return nil, genesisErr
@@ -127,7 +126,6 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
accountManager: ctx.AccountManager,
engine: CreateConsensusEngine(ctx, &config.Ethash, chainConfig, chainDb),
shutdownChan: make(chan bool),
- stopDbUpgrade: stopDbUpgrade,
networkId: config.NetworkId,
gasPrice: config.GasPrice,
etherbase: config.Etherbase,
@@ -138,11 +136,11 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
log.Info("Initialising Ethereum protocol", "versions", ProtocolVersions, "network", config.NetworkId)
if !config.SkipBcVersionCheck {
- bcVersion := core.GetBlockChainVersion(chainDb)
+ bcVersion := rawdb.ReadDatabaseVersion(chainDb)
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, core.BlockChainVersion)
+ rawdb.WriteDatabaseVersion(chainDb, core.BlockChainVersion)
}
var (
vmConfig = vm.Config{EnablePreimageRecording: config.EnablePreimageRecording}
@@ -156,7 +154,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
if compat, ok := genesisErr.(*params.ConfigCompatError); ok {
log.Warn("Rewinding chain to upgrade configuration", "err", compat)
eth.blockchain.SetHead(compat.RewindTo)
- core.WriteChainConfig(chainDb, genesisHash, chainConfig)
+ rawdb.WriteChainConfig(chainDb, genesisHash, chainConfig)
}
eth.bloomIndexer.Start(eth.blockchain)
@@ -411,9 +409,6 @@ func (s *Ethereum) Start(srvr *p2p.Server) error {
// Stop implements node.Service, terminating all internal goroutines used by the
// Ethereum protocol.
func (s *Ethereum) Stop() error {
- if s.stopDbUpgrade != nil {
- s.stopDbUpgrade()
- }
s.bloomIndexer.Close()
s.blockchain.Stop()
s.protocolManager.Stop()