Skip to content

Commit e61035c

Browse files
committed
cmd, eth, les, mobile: make networkid uint64 everywhere
1 parent ba3bcd1 commit e61035c

17 files changed

Lines changed: 38 additions & 38 deletions

File tree

‎cmd/faucet/faucet.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ var (
6161
apiPortFlag = flag.Int("apiport", 8080, "Listener port for the HTTP API connection")
6262
ethPortFlag = flag.Int("ethport", 30303, "Listener port for the devp2p connection")
6363
bootFlag = flag.String("bootnodes", "", "Comma separated bootnode enode URLs to seed with")
64-
netFlag = flag.Int("network", 0, "Network ID to use for the Ethereum protocol")
64+
netFlag = flag.Uint64("network", 0, "Network ID to use for the Ethereum protocol")
6565
statsFlag = flag.String("ethstats", "", "Ethstats network monitoring auth string")
6666

6767
netnameFlag = flag.String("faucet.name", "", "Network name to assign to the faucet")
@@ -179,7 +179,7 @@ type faucet struct {
179179
lock sync.RWMutex // Lock protecting the faucet's internals
180180
}
181181

182-
func newFaucet(genesis *core.Genesis, port int, enodes []*discv5.Node, network int, stats string, ks *keystore.KeyStore, index []byte) (*faucet, error) {
182+
func newFaucet(genesis *core.Genesis, port int, enodes []*discv5.Node, network uint64, stats string, ks *keystore.KeyStore, index []byte) (*faucet, error) {
183183
// Assemble the raw devp2p protocol stack
184184
stack, err := node.New(&node.Config{
185185
Name: "geth",

‎cmd/puppeth/wizard_genesis.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func (w *wizard) makeGenesis() {
120120
// Query the user for some custom extras
121121
fmt.Println()
122122
fmt.Println("Specify your chain/network ID if you want an explicit one (default = random)")
123-
genesis.Config.ChainId = big.NewInt(int64(w.readDefaultInt(rand.Intn(65536))))
123+
genesis.Config.ChainId = new(big.Int).SetUint64(uint64(w.readDefaultInt(rand.Intn(65536))))
124124

125125
fmt.Println()
126126
fmt.Println("Anything fun to embed into the genesis block? (max 32 bytes)")

‎cmd/utils/flags.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ var (
148148
Usage: "Number of recent ethash mining DAGs to keep on disk (1+GB each)",
149149
Value: eth.DefaultConfig.EthashDatasetsOnDisk,
150150
}
151-
NetworkIdFlag = cli.IntFlag{
151+
NetworkIdFlag = cli.Uint64Flag{
152152
Name: "networkid",
153153
Usage: "Network identifier (integer, 1=Frontier, 2=Morden (disused), 3=Ropsten)",
154154
Value: eth.DefaultConfig.NetworkId,
@@ -806,7 +806,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
806806
cfg.LightPeers = ctx.GlobalInt(LightPeersFlag.Name)
807807
}
808808
if ctx.GlobalIsSet(NetworkIdFlag.Name) {
809-
cfg.NetworkId = ctx.GlobalInt(NetworkIdFlag.Name)
809+
cfg.NetworkId = ctx.GlobalUint64(NetworkIdFlag.Name)
810810
}
811811

812812
// Ethereum needs to know maxPeers to calculate the light server peer ratio.

‎eth/backend.go‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ type Ethereum struct {
8080
MinerThreads int
8181
etherbase common.Address
8282

83-
netVersionId int
83+
networkId uint64
8484
netRPCService *ethapi.PublicNetAPI
8585
}
8686

@@ -118,7 +118,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
118118
engine: CreateConsensusEngine(ctx, config, chainConfig, chainDb),
119119
shutdownChan: make(chan bool),
120120
stopDbUpgrade: stopDbUpgrade,
121-
netVersionId: config.NetworkId,
121+
networkId: config.NetworkId,
122122
etherbase: config.Etherbase,
123123
MinerThreads: config.MinerThreads,
124124
}
@@ -347,7 +347,7 @@ func (s *Ethereum) Engine() consensus.Engine { return s.engine }
347347
func (s *Ethereum) ChainDb() ethdb.Database { return s.chainDb }
348348
func (s *Ethereum) IsListening() bool { return true } // Always listening
349349
func (s *Ethereum) EthVersion() int { return int(s.protocolManager.SubProtocols[0].Version) }
350-
func (s *Ethereum) NetVersion() int { return s.netVersionId }
350+
func (s *Ethereum) NetVersion() uint64 { return s.networkId }
351351
func (s *Ethereum) Downloader() *downloader.Downloader { return s.protocolManager.downloader }
352352

353353
// Protocols implements node.Service, returning all the currently configured

‎eth/config.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ type Config struct {
7272
Genesis *core.Genesis `toml:",omitempty"`
7373

7474
// Protocol options
75-
NetworkId int // Network ID to use for selecting peers to connect to
75+
NetworkId uint64 // Network ID to use for selecting peers to connect to
7676
SyncMode downloader.SyncMode
7777

7878
// Light client options

‎eth/gen_config.go‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎eth/handler.go‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func errResp(code errCode, format string, v ...interface{}) error {
6060
}
6161

6262
type ProtocolManager struct {
63-
networkId int
63+
networkId uint64
6464

6565
fastSync uint32 // Flag whether fast sync is enabled (gets disabled if we already have blocks)
6666
acceptTxs uint32 // Flag whether we're considered synchronised (enables transaction processing)
@@ -96,7 +96,7 @@ type ProtocolManager struct {
9696

9797
// NewProtocolManager returns a new ethereum sub protocol manager. The Ethereum sub protocol manages peers capable
9898
// with the ethereum network.
99-
func NewProtocolManager(config *params.ChainConfig, mode downloader.SyncMode, networkId int, maxPeers int, mux *event.TypeMux, txpool txPool, engine consensus.Engine, blockchain *core.BlockChain, chaindb ethdb.Database) (*ProtocolManager, error) {
99+
func NewProtocolManager(config *params.ChainConfig, mode downloader.SyncMode, networkId uint64, maxPeers int, mux *event.TypeMux, txpool txPool, engine consensus.Engine, blockchain *core.BlockChain, chaindb ethdb.Database) (*ProtocolManager, error) {
100100
// Create the protocol manager with the base fields
101101
manager := &ProtocolManager{
102102
networkId: networkId,
@@ -733,7 +733,7 @@ func (self *ProtocolManager) txBroadcastLoop() {
733733
// EthNodeInfo represents a short summary of the Ethereum sub-protocol metadata known
734734
// about the host peer.
735735
type EthNodeInfo struct {
736-
Network int `json:"network"` // Ethereum network ID (1=Frontier, 2=Morden, Ropsten=3)
736+
Network uint64 `json:"network"` // Ethereum network ID (1=Frontier, 2=Morden, Ropsten=3)
737737
Difficulty *big.Int `json:"difficulty"` // Total difficulty of the host's blockchain
738738
Genesis common.Hash `json:"genesis"` // SHA3 hash of the host's genesis block
739739
Head common.Hash `json:"head"` // SHA3 hash of the host's best owned block

‎eth/helper_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ func newTestPeer(name string, version int, pm *ProtocolManager, shake bool) (*te
173173
func (p *testPeer) handshake(t *testing.T, td *big.Int, head common.Hash, genesis common.Hash) {
174174
msg := &statusData{
175175
ProtocolVersion: uint32(p.version),
176-
NetworkId: uint32(DefaultConfig.NetworkId),
176+
NetworkId: DefaultConfig.NetworkId,
177177
TD: td,
178178
CurrentBlock: head,
179179
GenesisBlock: genesis,

‎eth/peer.go‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,15 +230,15 @@ func (p *peer) RequestReceipts(hashes []common.Hash) error {
230230

231231
// Handshake executes the eth protocol handshake, negotiating version number,
232232
// network IDs, difficulties, head and genesis blocks.
233-
func (p *peer) Handshake(network int, td *big.Int, head common.Hash, genesis common.Hash) error {
233+
func (p *peer) Handshake(network uint64, td *big.Int, head common.Hash, genesis common.Hash) error {
234234
// Send out own handshake in a new thread
235235
errc := make(chan error, 2)
236236
var status statusData // safe to read after two values have been received from errc
237237

238238
go func() {
239239
errc <- p2p.Send(p.rw, StatusMsg, &statusData{
240240
ProtocolVersion: uint32(p.version),
241-
NetworkId: uint32(network),
241+
NetworkId: network,
242242
TD: td,
243243
CurrentBlock: head,
244244
GenesisBlock: genesis,
@@ -263,7 +263,7 @@ func (p *peer) Handshake(network int, td *big.Int, head common.Hash, genesis com
263263
return nil
264264
}
265265

266-
func (p *peer) readStatus(network int, status *statusData, genesis common.Hash) (err error) {
266+
func (p *peer) readStatus(network uint64, status *statusData, genesis common.Hash) (err error) {
267267
msg, err := p.rw.ReadMsg()
268268
if err != nil {
269269
return err
@@ -281,7 +281,7 @@ func (p *peer) readStatus(network int, status *statusData, genesis common.Hash)
281281
if status.GenesisBlock != genesis {
282282
return errResp(ErrGenesisBlockMismatch, "%x (!= %x)", status.GenesisBlock[:8], genesis[:8])
283283
}
284-
if int(status.NetworkId) != network {
284+
if status.NetworkId != network {
285285
return errResp(ErrNetworkIdMismatch, "%d (!= %d)", status.NetworkId, network)
286286
}
287287
if int(status.ProtocolVersion) != p.version {

‎eth/protocol.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ type txPool interface {
105105
// statusData is the network packet for the status message.
106106
type statusData struct {
107107
ProtocolVersion uint32
108-
NetworkId uint32
108+
NetworkId uint64
109109
TD *big.Int
110110
CurrentBlock common.Hash
111111
GenesisBlock common.Hash

0 commit comments

Comments
 (0)