|
|
|
@ -58,7 +58,6 @@ var ( |
|
|
|
|
|
|
|
|
|
type Config struct { |
|
|
|
|
Name string |
|
|
|
|
ProtocolVersion int |
|
|
|
|
NetworkId int |
|
|
|
|
GenesisNonce int |
|
|
|
|
|
|
|
|
@ -226,7 +225,6 @@ type Ethereum struct { |
|
|
|
|
autodagquit chan bool |
|
|
|
|
etherbase common.Address |
|
|
|
|
clientVersion string |
|
|
|
|
ethVersionId int |
|
|
|
|
netVersionId int |
|
|
|
|
shhVersionId int |
|
|
|
|
} |
|
|
|
@ -291,6 +289,11 @@ func New(config *Config) (*Ethereum, error) { |
|
|
|
|
nodeDb := filepath.Join(config.DataDir, "nodes") |
|
|
|
|
|
|
|
|
|
// Perform database sanity checks
|
|
|
|
|
/* |
|
|
|
|
// 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 { |
|
|
|
@ -298,7 +301,8 @@ func New(config *Config) (*Ethereum, error) { |
|
|
|
|
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) |
|
|
|
|
*/ |
|
|
|
|
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,6 +670,11 @@ func (self *Ethereum) StopAutoDAG() { |
|
|
|
|
glog.V(logger.Info).Infof("Automatic pregeneration of ethash DAG OFF (ethash dir: %s)", ethash.DefaultDir) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
// 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() |
|
|
|
@ -675,6 +683,7 @@ func saveProtocolVersion(db common.Database, protov int) { |
|
|
|
|
db.Put([]byte("ProtocolVersion"), common.NewValue(protov).Bytes()) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
func saveBlockchainVersion(db common.Database, bcVersion int) { |
|
|
|
|
d, _ := db.Get([]byte("BlockchainVersion")) |
|
|
|
|