@@ -152,6 +152,10 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
152
152
if err != nil {
153
153
return nil , err
154
154
}
155
+ networkID := config .NetworkId
156
+ if networkID == 0 {
157
+ networkID = chainConfig .ChainID .Uint64 ()
158
+ }
155
159
eth := & Ethereum {
156
160
config : config ,
157
161
merger : consensus .NewMerger (chainDb ),
@@ -160,7 +164,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
160
164
accountManager : stack .AccountManager (),
161
165
engine : engine ,
162
166
closeBloomHandler : make (chan struct {}),
163
- networkID : config . NetworkId ,
167
+ networkID : networkID ,
164
168
gasPrice : config .Miner .GasPrice ,
165
169
etherbase : config .Miner .Etherbase ,
166
170
bloomRequests : make (chan chan * bloombits.Retrieval ),
@@ -173,7 +177,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
173
177
if bcVersion != nil {
174
178
dbVer = fmt .Sprintf ("%d" , * bcVersion )
175
179
}
176
- log .Info ("Initialising Ethereum protocol" , "network" , config . NetworkId , "dbversion" , dbVer )
180
+ log .Info ("Initialising Ethereum protocol" , "network" , networkID , "dbversion" , dbVer )
177
181
178
182
if ! config .SkipBcVersionCheck {
179
183
if bcVersion != nil && * bcVersion > core .BlockChainVersion {
@@ -236,7 +240,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
236
240
Chain : eth .blockchain ,
237
241
TxPool : eth .txPool ,
238
242
Merger : eth .merger ,
239
- Network : config . NetworkId ,
243
+ Network : networkID ,
240
244
Sync : config .SyncMode ,
241
245
BloomCache : uint64 (cacheLimit ),
242
246
EventMux : eth .eventMux ,
@@ -270,7 +274,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
270
274
}
271
275
272
276
// Start the RPC service
273
- eth .netRPCService = ethapi .NewNetAPI (eth .p2pServer , config . NetworkId )
277
+ eth .netRPCService = ethapi .NewNetAPI (eth .p2pServer , networkID )
274
278
275
279
// Register the backend on the node
276
280
stack .RegisterAPIs (eth .APIs ())
0 commit comments