diff options
Diffstat (limited to 'eth/backend.go')
-rw-r--r-- | eth/backend.go | 59 |
1 files changed, 34 insertions, 25 deletions
diff --git a/eth/backend.go b/eth/backend.go index 4644b8a93..23d76dfd1 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -57,10 +57,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 +225,6 @@ type Ethereum struct { autodagquit chan bool etherbase common.Address clientVersion string - ethVersionId int netVersionId int shhVersionId int } @@ -291,14 +289,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 +325,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 +348,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 +361,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 +498,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 +507,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 +563,7 @@ done: func (s *Ethereum) StartForTest() { jsonlogger.LogJson(&logger.LogStarting{ ClientString: s.net.Name, - ProtocolVersion: ProtocolVersion, + ProtocolVersion: s.EthVersion(), }) } @@ -667,14 +670,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")) |