aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwilliambannas <wrschwartz@wpi.edu>2018-06-14 18:14:52 +0800
committerPéter Szilágyi <peterke@gmail.com>2018-06-14 18:14:52 +0800
commit9402f965977620de0dcd968ad6943f66a80bcc5d (patch)
treeb3c6fc4a3aed4299117ff1e0aa83a84eff17cc70
parentd0fd8d6fc29ec859650adf30718e2b06786e854f (diff)
downloadgo-tangerine-9402f965977620de0dcd968ad6943f66a80bcc5d.tar
go-tangerine-9402f965977620de0dcd968ad6943f66a80bcc5d.tar.gz
go-tangerine-9402f965977620de0dcd968ad6943f66a80bcc5d.tar.bz2
go-tangerine-9402f965977620de0dcd968ad6943f66a80bcc5d.tar.lz
go-tangerine-9402f965977620de0dcd968ad6943f66a80bcc5d.tar.xz
go-tangerine-9402f965977620de0dcd968ad6943f66a80bcc5d.tar.zst
go-tangerine-9402f965977620de0dcd968ad6943f66a80bcc5d.zip
eth: conform better to the golint standards (#16783)
* eth: made changes to conform better to the golint standards * eth: fix comment nit
-rw-r--r--eth/api.go4
-rw-r--r--eth/api_backend.go1
-rw-r--r--eth/backend.go6
-rw-r--r--eth/downloader/downloader.go6
-rw-r--r--eth/downloader/queue.go10
-rw-r--r--eth/downloader/types.go16
-rw-r--r--eth/handler.go10
7 files changed, 27 insertions, 26 deletions
diff --git a/eth/api.go b/eth/api.go
index 446161cc4..0b6da456f 100644
--- a/eth/api.go
+++ b/eth/api.go
@@ -359,7 +359,7 @@ type BadBlockArgs struct {
RLP string `json:"rlp"`
}
-// GetBadBLocks returns a list of the last 'bad blocks' that the client has seen on the network
+// GetBadBlocks returns a list of the last 'bad blocks' that the client has seen on the network
// and returns them as a JSON list of block-hashes
func (api *PrivateDebugAPI) GetBadBlocks(ctx context.Context) ([]*BadBlockArgs, error) {
blocks := api.eth.BlockChain().BadBlocks()
@@ -431,7 +431,7 @@ func storageRangeAt(st state.Trie, start []byte, maxResult int) (StorageRangeRes
return result, nil
}
-// GetModifiedAccountsByumber returns all accounts that have changed between the
+// GetModifiedAccountsByNumber returns all accounts that have changed between the
// two blocks specified. A change is defined as a difference in nonce, balance,
// code hash, or storage hash.
//
diff --git a/eth/api_backend.go b/eth/api_backend.go
index 91a7dc7e0..016087dfe 100644
--- a/eth/api_backend.go
+++ b/eth/api_backend.go
@@ -43,6 +43,7 @@ type EthAPIBackend struct {
gpo *gasprice.Oracle
}
+// ChainConfig returns the active chain configuration.
func (b *EthAPIBackend) ChainConfig() *params.ChainConfig {
return b.eth.chainConfig
}
diff --git a/eth/backend.go b/eth/backend.go
index e07d5efc9..a18abdfb5 100644
--- a/eth/backend.go
+++ b/eth/backend.go
@@ -88,7 +88,7 @@ type Ethereum struct {
gasPrice *big.Int
etherbase common.Address
- networkId uint64
+ networkID uint64
netRPCService *ethapi.PublicNetAPI
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) {
accountManager: ctx.AccountManager,
engine: CreateConsensusEngine(ctx, &config.Ethash, chainConfig, chainDb),
shutdownChan: make(chan bool),
- networkId: config.NetworkId,
+ networkID: config.NetworkId,
gasPrice: config.GasPrice,
etherbase: config.Etherbase,
bloomRequests: make(chan chan *bloombits.Retrieval),
@@ -369,7 +369,7 @@ func (s *Ethereum) Engine() consensus.Engine { return s.engine }
func (s *Ethereum) ChainDb() ethdb.Database { return s.chainDb }
func (s *Ethereum) IsListening() bool { return true } // Always listening
func (s *Ethereum) EthVersion() int { return int(s.protocolManager.SubProtocols[0].Version) }
-func (s *Ethereum) NetVersion() uint64 { return s.networkId }
+func (s *Ethereum) NetVersion() uint64 { return s.networkID }
func (s *Ethereum) Downloader() *downloader.Downloader { return s.protocolManager.downloader }
// Protocols implements node.Service, returning all the currently configured
diff --git a/eth/downloader/downloader.go b/eth/downloader/downloader.go
index 51c593601..fbde9c6ca 100644
--- a/eth/downloader/downloader.go
+++ b/eth/downloader/downloader.go
@@ -900,7 +900,7 @@ func (d *Downloader) fillHeaderSkeleton(from uint64, skeleton []*types.Header) (
var (
deliver = func(packet dataPack) (int, error) {
pack := packet.(*headerPack)
- return d.queue.DeliverHeaders(pack.peerId, pack.headers, d.headerProcCh)
+ return d.queue.DeliverHeaders(pack.peerID, pack.headers, d.headerProcCh)
}
expire = func() map[string]int { return d.queue.ExpireHeaders(d.requestTTL()) }
throttle = func() bool { return false }
@@ -930,7 +930,7 @@ func (d *Downloader) fetchBodies(from uint64) error {
var (
deliver = func(packet dataPack) (int, error) {
pack := packet.(*bodyPack)
- return d.queue.DeliverBodies(pack.peerId, pack.transactions, pack.uncles)
+ return d.queue.DeliverBodies(pack.peerID, pack.transactions, pack.uncles)
}
expire = func() map[string]int { return d.queue.ExpireBodies(d.requestTTL()) }
fetch = func(p *peerConnection, req *fetchRequest) error { return p.FetchBodies(req) }
@@ -954,7 +954,7 @@ func (d *Downloader) fetchReceipts(from uint64) error {
var (
deliver = func(packet dataPack) (int, error) {
pack := packet.(*receiptPack)
- return d.queue.DeliverReceipts(pack.peerId, pack.receipts)
+ return d.queue.DeliverReceipts(pack.peerID, pack.receipts)
}
expire = func() map[string]int { return d.queue.ExpireReceipts(d.requestTTL()) }
fetch = func(p *peerConnection, req *fetchRequest) error { return p.FetchReceipts(req) }
diff --git a/eth/downloader/queue.go b/eth/downloader/queue.go
index bbe0aed5d..984dd13d6 100644
--- a/eth/downloader/queue.go
+++ b/eth/downloader/queue.go
@@ -596,21 +596,21 @@ func (q *queue) cancel(request *fetchRequest, taskQueue *prque.Prque, pendPool m
// Revoke cancels all pending requests belonging to a given peer. This method is
// meant to be called during a peer drop to quickly reassign owned data fetches
// to remaining nodes.
-func (q *queue) Revoke(peerId string) {
+func (q *queue) Revoke(peerID string) {
q.lock.Lock()
defer q.lock.Unlock()
- if request, ok := q.blockPendPool[peerId]; ok {
+ if request, ok := q.blockPendPool[peerID]; ok {
for _, header := range request.Headers {
q.blockTaskQueue.Push(header, -float32(header.Number.Uint64()))
}
- delete(q.blockPendPool, peerId)
+ delete(q.blockPendPool, peerID)
}
- if request, ok := q.receiptPendPool[peerId]; ok {
+ if request, ok := q.receiptPendPool[peerID]; ok {
for _, header := range request.Headers {
q.receiptTaskQueue.Push(header, -float32(header.Number.Uint64()))
}
- delete(q.receiptPendPool, peerId)
+ delete(q.receiptPendPool, peerID)
}
}
diff --git a/eth/downloader/types.go b/eth/downloader/types.go
index 3f30ea9dd..ff70bfa0e 100644
--- a/eth/downloader/types.go
+++ b/eth/downloader/types.go
@@ -34,22 +34,22 @@ type dataPack interface {
// headerPack is a batch of block headers returned by a peer.
type headerPack struct {
- peerId string
+ peerID string
headers []*types.Header
}
-func (p *headerPack) PeerId() string { return p.peerId }
+func (p *headerPack) PeerId() string { return p.peerID }
func (p *headerPack) Items() int { return len(p.headers) }
func (p *headerPack) Stats() string { return fmt.Sprintf("%d", len(p.headers)) }
// bodyPack is a batch of block bodies returned by a peer.
type bodyPack struct {
- peerId string
+ peerID string
transactions [][]*types.Transaction
uncles [][]*types.Header
}
-func (p *bodyPack) PeerId() string { return p.peerId }
+func (p *bodyPack) PeerId() string { return p.peerID }
func (p *bodyPack) Items() int {
if len(p.transactions) <= len(p.uncles) {
return len(p.transactions)
@@ -60,20 +60,20 @@ func (p *bodyPack) Stats() string { return fmt.Sprintf("%d:%d", len(p.transactio
// receiptPack is a batch of receipts returned by a peer.
type receiptPack struct {
- peerId string
+ peerID string
receipts [][]*types.Receipt
}
-func (p *receiptPack) PeerId() string { return p.peerId }
+func (p *receiptPack) PeerId() string { return p.peerID }
func (p *receiptPack) Items() int { return len(p.receipts) }
func (p *receiptPack) Stats() string { return fmt.Sprintf("%d", len(p.receipts)) }
// statePack is a batch of states returned by a peer.
type statePack struct {
- peerId string
+ peerID string
states [][]byte
}
-func (p *statePack) PeerId() string { return p.peerId }
+func (p *statePack) PeerId() string { return p.peerID }
func (p *statePack) Items() int { return len(p.states) }
func (p *statePack) Stats() string { return fmt.Sprintf("%d", len(p.states)) }
diff --git a/eth/handler.go b/eth/handler.go
index a46e7f13c..f2d2eaf1c 100644
--- a/eth/handler.go
+++ b/eth/handler.go
@@ -64,7 +64,7 @@ func errResp(code errCode, format string, v ...interface{}) error {
}
type ProtocolManager struct {
- networkId uint64
+ networkID uint64
fastSync uint32 // Flag whether fast sync is enabled (gets disabled if we already have blocks)
acceptTxs uint32 // Flag whether we're considered synchronised (enables transaction processing)
@@ -98,10 +98,10 @@ type ProtocolManager struct {
// NewProtocolManager returns a new Ethereum sub protocol manager. The Ethereum sub protocol manages peers capable
// with the Ethereum network.
-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) {
+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) {
// Create the protocol manager with the base fields
manager := &ProtocolManager{
- networkId: networkId,
+ networkID: networkID,
eventMux: mux,
txpool: txpool,
blockchain: blockchain,
@@ -263,7 +263,7 @@ func (pm *ProtocolManager) handle(p *peer) error {
number = head.Number.Uint64()
td = pm.blockchain.GetTd(hash, number)
)
- if err := p.Handshake(pm.networkId, td, hash, genesis.Hash()); err != nil {
+ if err := p.Handshake(pm.networkID, td, hash, genesis.Hash()); err != nil {
p.Log().Debug("Ethereum handshake failed", "err", err)
return err
}
@@ -779,7 +779,7 @@ type NodeInfo struct {
func (pm *ProtocolManager) NodeInfo() *NodeInfo {
currentBlock := pm.blockchain.CurrentBlock()
return &NodeInfo{
- Network: pm.networkId,
+ Network: pm.networkID,
Difficulty: pm.blockchain.GetTd(currentBlock.Hash(), currentBlock.NumberU64()),
Genesis: pm.blockchain.Genesis().Hash(),
Config: pm.blockchain.Config(),