aboutsummaryrefslogtreecommitdiffstats
path: root/eth/backend.go
diff options
context:
space:
mode:
Diffstat (limited to 'eth/backend.go')
-rw-r--r--eth/backend.go62
1 files changed, 35 insertions, 27 deletions
diff --git a/eth/backend.go b/eth/backend.go
index 4644b8a93..d6ad3381d 100644
--- a/eth/backend.go
+++ b/eth/backend.go
@@ -11,8 +11,6 @@ import (
"strings"
"time"
- "github.com/ethereum/go-ethereum/metrics"
-
"github.com/ethereum/ethash"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/common"
@@ -26,6 +24,7 @@ import (
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger/glog"
+ "github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/miner"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p/discover"
@@ -57,10 +56,9 @@ var (
)
type Config struct {
- Name string
- ProtocolVersion int
- NetworkId int
- GenesisNonce int
+ Name string
+ NetworkId int
+ GenesisNonce int
BlockChainVersion int
SkipBcVersionCheck bool // e.g. blockchain export
@@ -226,7 +224,6 @@ type Ethereum struct {
autodagquit chan bool
etherbase common.Address
clientVersion string
- ethVersionId int
netVersionId int
shhVersionId int
}
@@ -291,14 +288,20 @@ func New(config *Config) (*Ethereum, error) {
nodeDb := filepath.Join(config.DataDir, "nodes")
// Perform database sanity checks
- d, _ := blockDb.Get([]byte("ProtocolVersion"))
- protov := int(common.NewValue(d).Uint())
- if protov != config.ProtocolVersion && protov != 0 {
- path := filepath.Join(config.DataDir, "blockchain")
- return nil, fmt.Errorf("Database version mismatch. Protocol(%d / %d). `rm -rf %s`", protov, config.ProtocolVersion, path)
- }
- saveProtocolVersion(blockDb, config.ProtocolVersion)
- glog.V(logger.Info).Infof("Protocol Version: %v, Network Id: %v", config.ProtocolVersion, config.NetworkId)
+ /*
+ // The databases were previously tied to protocol versions. Currently we
+ // are moving away from this decision as approaching Frontier. The below
+ // check was left in for now but should eventually be just dropped.
+
+ d, _ := blockDb.Get([]byte("ProtocolVersion"))
+ protov := int(common.NewValue(d).Uint())
+ if protov != config.ProtocolVersion && protov != 0 {
+ path := filepath.Join(config.DataDir, "blockchain")
+ return nil, fmt.Errorf("Database version mismatch. Protocol(%d / %d). `rm -rf %s`", protov, config.ProtocolVersion, path)
+ }
+ saveProtocolVersion(blockDb, config.ProtocolVersion)
+ */
+ glog.V(logger.Info).Infof("Protocol Versions: %v, Network Id: %v", ProtocolVersions, config.NetworkId)
if !config.SkipBcVersionCheck {
b, _ := blockDb.Get([]byte("BlockchainVersion"))
@@ -321,7 +324,6 @@ func New(config *Config) (*Ethereum, error) {
DataDir: config.DataDir,
etherbase: common.HexToAddress(config.Etherbase),
clientVersion: config.Name, // TODO should separate from Name
- ethVersionId: config.ProtocolVersion,
netVersionId: config.NetworkId,
NatSpec: config.NatSpec,
MinerThreads: config.MinerThreads,
@@ -345,7 +347,7 @@ func New(config *Config) (*Ethereum, error) {
eth.blockProcessor = core.NewBlockProcessor(stateDb, extraDb, eth.pow, eth.chainManager, eth.EventMux())
eth.chainManager.SetProcessor(eth.blockProcessor)
- eth.protocolManager = NewProtocolManager(config.ProtocolVersion, config.NetworkId, eth.eventMux, eth.txPool, eth.pow, eth.chainManager)
+ eth.protocolManager = NewProtocolManager(config.NetworkId, eth.eventMux, eth.txPool, eth.pow, eth.chainManager)
eth.miner = miner.New(eth, eth.EventMux(), eth.pow)
eth.miner.SetGasPrice(config.GasPrice)
@@ -358,7 +360,7 @@ func New(config *Config) (*Ethereum, error) {
if err != nil {
return nil, err
}
- protocols := []p2p.Protocol{eth.protocolManager.SubProtocol}
+ protocols := append([]p2p.Protocol{}, eth.protocolManager.SubProtocols...)
if config.Shh {
protocols = append(protocols, eth.whisper.Protocol())
}
@@ -495,7 +497,7 @@ func (s *Ethereum) PeerCount() int { return s.net.PeerCoun
func (s *Ethereum) Peers() []*p2p.Peer { return s.net.Peers() }
func (s *Ethereum) MaxPeers() int { return s.net.MaxPeers }
func (s *Ethereum) ClientVersion() string { return s.clientVersion }
-func (s *Ethereum) EthVersion() int { return s.ethVersionId }
+func (s *Ethereum) EthVersion() int { return int(s.protocolManager.SubProtocols[0].Version) }
func (s *Ethereum) NetVersion() int { return s.netVersionId }
func (s *Ethereum) ShhVersion() int { return s.shhVersionId }
func (s *Ethereum) Downloader() *downloader.Downloader { return s.protocolManager.downloader }
@@ -504,7 +506,7 @@ func (s *Ethereum) Downloader() *downloader.Downloader { return s.protocolMana
func (s *Ethereum) Start() error {
jsonlogger.LogJson(&logger.LogStarting{
ClientString: s.net.Name,
- ProtocolVersion: ProtocolVersion,
+ ProtocolVersion: s.EthVersion(),
})
err := s.net.Start()
if err != nil {
@@ -560,7 +562,7 @@ done:
func (s *Ethereum) StartForTest() {
jsonlogger.LogJson(&logger.LogStarting{
ClientString: s.net.Name,
- ProtocolVersion: ProtocolVersion,
+ ProtocolVersion: s.EthVersion(),
})
}
@@ -667,14 +669,20 @@ func (self *Ethereum) StopAutoDAG() {
glog.V(logger.Info).Infof("Automatic pregeneration of ethash DAG OFF (ethash dir: %s)", ethash.DefaultDir)
}
-func saveProtocolVersion(db common.Database, protov int) {
- d, _ := db.Get([]byte("ProtocolVersion"))
- protocolVersion := common.NewValue(d).Uint()
+/*
+ // The databases were previously tied to protocol versions. Currently we
+ // are moving away from this decision as approaching Frontier. The below
+ // code was left in for now but should eventually be just dropped.
+
+ func saveProtocolVersion(db common.Database, protov int) {
+ d, _ := db.Get([]byte("ProtocolVersion"))
+ protocolVersion := common.NewValue(d).Uint()
- if protocolVersion == 0 {
- db.Put([]byte("ProtocolVersion"), common.NewValue(protov).Bytes())
+ if protocolVersion == 0 {
+ db.Put([]byte("ProtocolVersion"), common.NewValue(protov).Bytes())
+ }
}
-}
+*/
func saveBlockchainVersion(db common.Database, bcVersion int) {
d, _ := db.Get([]byte("BlockchainVersion"))