mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
eth: set networkID to chainID by default
This commit is contained in:
parent
de2259d27c
commit
d2a8cc62ad
2 changed files with 12 additions and 6 deletions
|
|
@ -141,6 +141,10 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
|
|||
}
|
||||
log.Info("Initialised chain configuration", "config", chainConfig)
|
||||
|
||||
networkID := config.NetworkId
|
||||
if networkID == 0 {
|
||||
networkID = chainConfig.ChainID.Uint64()
|
||||
}
|
||||
eth := &Ethereum{
|
||||
config: config,
|
||||
chainDb: chainDb,
|
||||
|
|
@ -148,7 +152,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
|
|||
accountManager: ctx.AccountManager,
|
||||
engine: CreateConsensusEngine(ctx, chainConfig, &config.Ethash, config.Miner.Notify, config.Miner.Noverify, chainDb),
|
||||
shutdownChan: make(chan bool),
|
||||
networkID: config.NetworkId,
|
||||
networkID: networkID,
|
||||
gasPrice: config.Miner.GasPrice,
|
||||
etherbase: config.Miner.Etherbase,
|
||||
bloomRequests: make(chan chan *bloombits.Retrieval),
|
||||
|
|
@ -160,7 +164,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
|
|||
if bcVersion != nil {
|
||||
dbVer = fmt.Sprintf("%d", *bcVersion)
|
||||
}
|
||||
log.Info("Initialising Ethereum protocol", "versions", ProtocolVersions, "network", config.NetworkId, "dbversion", dbVer)
|
||||
log.Info("Initialising Ethereum protocol", "versions", ProtocolVersions, "network", networkID, "dbversion", dbVer)
|
||||
|
||||
if !config.SkipBcVersionCheck {
|
||||
if bcVersion != nil && *bcVersion > core.BlockChainVersion {
|
||||
|
|
@ -207,7 +211,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
|
|||
if checkpoint == nil {
|
||||
checkpoint = params.TrustedCheckpoints[genesisHash]
|
||||
}
|
||||
if eth.protocolManager, err = NewProtocolManager(chainConfig, checkpoint, config.SyncMode, config.NetworkId, eth.eventMux, eth.txPool, eth.engine, eth.blockchain, chainDb, cacheLimit, config.Whitelist); err != nil {
|
||||
if eth.protocolManager, err = NewProtocolManager(chainConfig, checkpoint, config.SyncMode, networkID, eth.eventMux, eth.txPool, eth.engine, eth.blockchain, chainDb, cacheLimit, config.Whitelist); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
eth.miner = miner.New(eth, &config.Miner, chainConfig, eth.EventMux(), eth.engine, eth.isLocalBlock)
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ var DefaultConfig = Config{
|
|||
DatasetsInMem: 1,
|
||||
DatasetsOnDisk: 2,
|
||||
},
|
||||
NetworkId: 1,
|
||||
NetworkId: 0,
|
||||
LightPeers: 100,
|
||||
UltraLightFraction: 75,
|
||||
DatabaseCache: 512,
|
||||
|
|
@ -91,8 +91,10 @@ type Config struct {
|
|||
// If nil, the Ethereum main net block is used.
|
||||
Genesis *core.Genesis `toml:",omitempty"`
|
||||
|
||||
// Protocol options
|
||||
NetworkId uint64 // Network ID to use for selecting peers to connect to
|
||||
// Network ID separates blockchains on the peer-to-peer networking level. When left
|
||||
// zero, the chain ID is used as network ID.
|
||||
NetworkId uint64
|
||||
|
||||
SyncMode downloader.SyncMode
|
||||
|
||||
NoPruning bool // Whether to disable pruning and flush everything to disk
|
||||
|
|
|
|||
Loading…
Reference in a new issue