Skip to content

Commit 9402f96

Browse files
williambannaskaralabe
authored andcommitted
eth: conform better to the golint standards (#16783)
* eth: made changes to conform better to the golint standards * eth: fix comment nit
1 parent d0fd8d6 commit 9402f96

7 files changed

Lines changed: 27 additions & 26 deletions

File tree

‎eth/api.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ type BadBlockArgs struct {
359359
RLP string `json:"rlp"`
360360
}
361361

362-
// GetBadBLocks returns a list of the last 'bad blocks' that the client has seen on the network
362+
// GetBadBlocks returns a list of the last 'bad blocks' that the client has seen on the network
363363
// and returns them as a JSON list of block-hashes
364364
func (api *PrivateDebugAPI) GetBadBlocks(ctx context.Context) ([]*BadBlockArgs, error) {
365365
blocks := api.eth.BlockChain().BadBlocks()
@@ -431,7 +431,7 @@ func storageRangeAt(st state.Trie, start []byte, maxResult int) (StorageRangeRes
431431
return result, nil
432432
}
433433

434-
// GetModifiedAccountsByumber returns all accounts that have changed between the
434+
// GetModifiedAccountsByNumber returns all accounts that have changed between the
435435
// two blocks specified. A change is defined as a difference in nonce, balance,
436436
// code hash, or storage hash.
437437
//

‎eth/api_backend.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ type EthAPIBackend struct {
4343
gpo *gasprice.Oracle
4444
}
4545

46+
// ChainConfig returns the active chain configuration.
4647
func (b *EthAPIBackend) ChainConfig() *params.ChainConfig {
4748
return b.eth.chainConfig
4849
}

‎eth/backend.go‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ type Ethereum struct {
8888
gasPrice *big.Int
8989
etherbase common.Address
9090

91-
networkId uint64
91+
networkID uint64
9292
netRPCService *ethapi.PublicNetAPI
9393

9494
lock sync.RWMutex // Protects the variadic fields (e.g. gas price and etherbase)
@@ -126,7 +126,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
126126
accountManager: ctx.AccountManager,
127127
engine: CreateConsensusEngine(ctx, &config.Ethash, chainConfig, chainDb),
128128
shutdownChan: make(chan bool),
129-
networkId: config.NetworkId,
129+
networkID: config.NetworkId,
130130
gasPrice: config.GasPrice,
131131
etherbase: config.Etherbase,
132132
bloomRequests: make(chan chan *bloombits.Retrieval),
@@ -369,7 +369,7 @@ func (s *Ethereum) Engine() consensus.Engine { return s.engine }
369369
func (s *Ethereum) ChainDb() ethdb.Database { return s.chainDb }
370370
func (s *Ethereum) IsListening() bool { return true } // Always listening
371371
func (s *Ethereum) EthVersion() int { return int(s.protocolManager.SubProtocols[0].Version) }
372-
func (s *Ethereum) NetVersion() uint64 { return s.networkId }
372+
func (s *Ethereum) NetVersion() uint64 { return s.networkID }
373373
func (s *Ethereum) Downloader() *downloader.Downloader { return s.protocolManager.downloader }
374374

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

‎eth/downloader/downloader.go‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,7 @@ func (d *Downloader) fillHeaderSkeleton(from uint64, skeleton []*types.Header) (
900900
var (
901901
deliver = func(packet dataPack) (int, error) {
902902
pack := packet.(*headerPack)
903-
return d.queue.DeliverHeaders(pack.peerId, pack.headers, d.headerProcCh)
903+
return d.queue.DeliverHeaders(pack.peerID, pack.headers, d.headerProcCh)
904904
}
905905
expire = func() map[string]int { return d.queue.ExpireHeaders(d.requestTTL()) }
906906
throttle = func() bool { return false }
@@ -930,7 +930,7 @@ func (d *Downloader) fetchBodies(from uint64) error {
930930
var (
931931
deliver = func(packet dataPack) (int, error) {
932932
pack := packet.(*bodyPack)
933-
return d.queue.DeliverBodies(pack.peerId, pack.transactions, pack.uncles)
933+
return d.queue.DeliverBodies(pack.peerID, pack.transactions, pack.uncles)
934934
}
935935
expire = func() map[string]int { return d.queue.ExpireBodies(d.requestTTL()) }
936936
fetch = func(p *peerConnection, req *fetchRequest) error { return p.FetchBodies(req) }
@@ -954,7 +954,7 @@ func (d *Downloader) fetchReceipts(from uint64) error {
954954
var (
955955
deliver = func(packet dataPack) (int, error) {
956956
pack := packet.(*receiptPack)
957-
return d.queue.DeliverReceipts(pack.peerId, pack.receipts)
957+
return d.queue.DeliverReceipts(pack.peerID, pack.receipts)
958958
}
959959
expire = func() map[string]int { return d.queue.ExpireReceipts(d.requestTTL()) }
960960
fetch = func(p *peerConnection, req *fetchRequest) error { return p.FetchReceipts(req) }

‎eth/downloader/queue.go‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -596,21 +596,21 @@ func (q *queue) cancel(request *fetchRequest, taskQueue *prque.Prque, pendPool m
596596
// Revoke cancels all pending requests belonging to a given peer. This method is
597597
// meant to be called during a peer drop to quickly reassign owned data fetches
598598
// to remaining nodes.
599-
func (q *queue) Revoke(peerId string) {
599+
func (q *queue) Revoke(peerID string) {
600600
q.lock.Lock()
601601
defer q.lock.Unlock()
602602

603-
if request, ok := q.blockPendPool[peerId]; ok {
603+
if request, ok := q.blockPendPool[peerID]; ok {
604604
for _, header := range request.Headers {
605605
q.blockTaskQueue.Push(header, -float32(header.Number.Uint64()))
606606
}
607-
delete(q.blockPendPool, peerId)
607+
delete(q.blockPendPool, peerID)
608608
}
609-
if request, ok := q.receiptPendPool[peerId]; ok {
609+
if request, ok := q.receiptPendPool[peerID]; ok {
610610
for _, header := range request.Headers {
611611
q.receiptTaskQueue.Push(header, -float32(header.Number.Uint64()))
612612
}
613-
delete(q.receiptPendPool, peerId)
613+
delete(q.receiptPendPool, peerID)
614614
}
615615
}
616616

‎eth/downloader/types.go‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,22 @@ type dataPack interface {
3434

3535
// headerPack is a batch of block headers returned by a peer.
3636
type headerPack struct {
37-
peerId string
37+
peerID string
3838
headers []*types.Header
3939
}
4040

41-
func (p *headerPack) PeerId() string { return p.peerId }
41+
func (p *headerPack) PeerId() string { return p.peerID }
4242
func (p *headerPack) Items() int { return len(p.headers) }
4343
func (p *headerPack) Stats() string { return fmt.Sprintf("%d", len(p.headers)) }
4444

4545
// bodyPack is a batch of block bodies returned by a peer.
4646
type bodyPack struct {
47-
peerId string
47+
peerID string
4848
transactions [][]*types.Transaction
4949
uncles [][]*types.Header
5050
}
5151

52-
func (p *bodyPack) PeerId() string { return p.peerId }
52+
func (p *bodyPack) PeerId() string { return p.peerID }
5353
func (p *bodyPack) Items() int {
5454
if len(p.transactions) <= len(p.uncles) {
5555
return len(p.transactions)
@@ -60,20 +60,20 @@ func (p *bodyPack) Stats() string { return fmt.Sprintf("%d:%d", len(p.transactio
6060

6161
// receiptPack is a batch of receipts returned by a peer.
6262
type receiptPack struct {
63-
peerId string
63+
peerID string
6464
receipts [][]*types.Receipt
6565
}
6666

67-
func (p *receiptPack) PeerId() string { return p.peerId }
67+
func (p *receiptPack) PeerId() string { return p.peerID }
6868
func (p *receiptPack) Items() int { return len(p.receipts) }
6969
func (p *receiptPack) Stats() string { return fmt.Sprintf("%d", len(p.receipts)) }
7070

7171
// statePack is a batch of states returned by a peer.
7272
type statePack struct {
73-
peerId string
73+
peerID string
7474
states [][]byte
7575
}
7676

77-
func (p *statePack) PeerId() string { return p.peerId }
77+
func (p *statePack) PeerId() string { return p.peerID }
7878
func (p *statePack) Items() int { return len(p.states) }
7979
func (p *statePack) Stats() string { return fmt.Sprintf("%d", len(p.states)) }

‎eth/handler.go‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func errResp(code errCode, format string, v ...interface{}) error {
6464
}
6565

6666
type ProtocolManager struct {
67-
networkId uint64
67+
networkID uint64
6868

6969
fastSync uint32 // Flag whether fast sync is enabled (gets disabled if we already have blocks)
7070
acceptTxs uint32 // Flag whether we're considered synchronised (enables transaction processing)
@@ -98,10 +98,10 @@ type ProtocolManager struct {
9898

9999
// NewProtocolManager returns a new Ethereum sub protocol manager. The Ethereum sub protocol manages peers capable
100100
// with the Ethereum network.
101-
func NewProtocolManager(config *params.ChainConfig, mode downloader.SyncMode, networkId uint64, mux *event.TypeMux, txpool txPool, engine consensus.Engine, blockchain *core.BlockChain, chaindb ethdb.Database) (*ProtocolManager, error) {
101+
func NewProtocolManager(config *params.ChainConfig, mode downloader.SyncMode, networkID uint64, mux *event.TypeMux, txpool txPool, engine consensus.Engine, blockchain *core.BlockChain, chaindb ethdb.Database) (*ProtocolManager, error) {
102102
// Create the protocol manager with the base fields
103103
manager := &ProtocolManager{
104-
networkId: networkId,
104+
networkID: networkID,
105105
eventMux: mux,
106106
txpool: txpool,
107107
blockchain: blockchain,
@@ -263,7 +263,7 @@ func (pm *ProtocolManager) handle(p *peer) error {
263263
number = head.Number.Uint64()
264264
td = pm.blockchain.GetTd(hash, number)
265265
)
266-
if err := p.Handshake(pm.networkId, td, hash, genesis.Hash()); err != nil {
266+
if err := p.Handshake(pm.networkID, td, hash, genesis.Hash()); err != nil {
267267
p.Log().Debug("Ethereum handshake failed", "err", err)
268268
return err
269269
}
@@ -779,7 +779,7 @@ type NodeInfo struct {
779779
func (pm *ProtocolManager) NodeInfo() *NodeInfo {
780780
currentBlock := pm.blockchain.CurrentBlock()
781781
return &NodeInfo{
782-
Network: pm.networkId,
782+
Network: pm.networkID,
783783
Difficulty: pm.blockchain.GetTd(currentBlock.Hash(), currentBlock.NumberU64()),
784784
Genesis: pm.blockchain.Genesis().Hash(),
785785
Config: pm.blockchain.Config(),

0 commit comments

Comments
 (0)