internal/ethapi: golint fixes

This commit is contained in:
Mike Kinney 2019-12-09 21:24:38 -08:00
parent 0a049eeb00
commit f5cf260309
3 changed files with 14 additions and 9 deletions

View file

@ -22,6 +22,7 @@ import (
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
) )
// AddrLocker is a stuct with the mutex and locks map
type AddrLocker struct { type AddrLocker struct {
mu sync.Mutex mu sync.Mutex
locks map[common.Address]*sync.Mutex locks map[common.Address]*sync.Mutex

View file

@ -212,14 +212,14 @@ func NewPrivateAccountAPI(b Backend, nonceLock *AddrLocker) *PrivateAccountAPI {
} }
} }
// listAccounts will return a list of addresses for accounts this node manages. // ListAccounts will return a list of addresses for accounts this node manages.
func (s *PrivateAccountAPI) ListAccounts() []common.Address { func (s *PrivateAccountAPI) ListAccounts() []common.Address {
return s.am.Accounts() return s.am.Accounts()
} }
// rawWallet is a JSON representation of an accounts.Wallet interface, with its // RawWallet is a JSON representation of an accounts.Wallet interface, with its
// data contents extracted into plain fields. // data contents extracted into plain fields.
type rawWallet struct { type RawWallet struct {
URL string `json:"url"` URL string `json:"url"`
Status string `json:"status"` Status string `json:"status"`
Failure string `json:"failure,omitempty"` Failure string `json:"failure,omitempty"`
@ -227,12 +227,12 @@ type rawWallet struct {
} }
// ListWallets will return a list of wallets this node manages. // ListWallets will return a list of wallets this node manages.
func (s *PrivateAccountAPI) ListWallets() []rawWallet { func (s *PrivateAccountAPI) ListWallets() []RawWallet {
wallets := make([]rawWallet, 0) // return [] instead of nil if empty wallets := make([]RawWallet, 0) // return [] instead of nil if empty
for _, wallet := range s.am.Wallets() { for _, wallet := range s.am.Wallets() {
status, failure := wallet.Status() status, failure := wallet.Status()
raw := rawWallet{ raw := RawWallet{
URL: wallet.URL().String(), URL: wallet.URL().String(),
Status: status, Status: status,
Accounts: wallet.Accounts(), Accounts: wallet.Accounts(),
@ -516,8 +516,8 @@ func NewPublicBlockChainAPI(b Backend) *PublicBlockChainAPI {
return &PublicBlockChainAPI{b} return &PublicBlockChainAPI{b}
} }
// ChainId returns the chainID value for transaction replay protection. // ChainID returns the chainID value for transaction replay protection.
func (s *PublicBlockChainAPI) ChainId() *hexutil.Big { func (s *PublicBlockChainAPI) ChainID() *hexutil.Big {
return (*hexutil.Big)(s.b.ChainConfig().ChainID) return (*hexutil.Big)(s.b.ChainConfig().ChainID)
} }
@ -538,7 +538,7 @@ func (s *PublicBlockChainAPI) GetBalance(ctx context.Context, address common.Add
return (*hexutil.Big)(state.GetBalance(address)), state.Error() return (*hexutil.Big)(state.GetBalance(address)), state.Error()
} }
// Result structs for GetProof // AccountResult is a struct for GetProof
type AccountResult struct { type AccountResult struct {
Address common.Address `json:"address"` Address common.Address `json:"address"`
AccountProof []string `json:"accountProof"` AccountProof []string `json:"accountProof"`
@ -548,6 +548,7 @@ type AccountResult struct {
StorageHash common.Hash `json:"storageHash"` StorageHash common.Hash `json:"storageHash"`
StorageProof []StorageResult `json:"storageProof"` StorageProof []StorageResult `json:"storageProof"`
} }
// StorageResult is a struct for storing proofs
type StorageResult struct { type StorageResult struct {
Key string `json:"key"` Key string `json:"key"`
Value *hexutil.Big `json:"value"` Value *hexutil.Big `json:"value"`
@ -757,6 +758,7 @@ type account struct {
StateDiff *map[common.Hash]common.Hash `json:"stateDiff"` StateDiff *map[common.Hash]common.Hash `json:"stateDiff"`
} }
// DoCall will execute an EVM call
func DoCall(ctx context.Context, b Backend, args CallArgs, blockNrOrHash rpc.BlockNumberOrHash, overrides map[common.Address]account, vmCfg vm.Config, timeout time.Duration, globalGasCap *big.Int) ([]byte, uint64, bool, error) { func DoCall(ctx context.Context, b Backend, args CallArgs, blockNrOrHash rpc.BlockNumberOrHash, overrides map[common.Address]account, vmCfg vm.Config, timeout time.Duration, globalGasCap *big.Int) ([]byte, uint64, bool, error) {
defer func(start time.Time) { log.Debug("Executing EVM call finished", "runtime", time.Since(start)) }(time.Now()) defer func(start time.Time) { log.Debug("Executing EVM call finished", "runtime", time.Since(start)) }(time.Now())
@ -883,6 +885,7 @@ func (s *PublicBlockChainAPI) Call(ctx context.Context, args CallArgs, blockNrOr
return (hexutil.Bytes)(result), err return (hexutil.Bytes)(result), err
} }
// DoEstimateGas will estimate the gas
func DoEstimateGas(ctx context.Context, b Backend, args CallArgs, blockNrOrHash rpc.BlockNumberOrHash, gasCap *big.Int) (hexutil.Uint64, error) { func DoEstimateGas(ctx context.Context, b Backend, args CallArgs, blockNrOrHash rpc.BlockNumberOrHash, gasCap *big.Int) (hexutil.Uint64, error) {
// Binary search the gas requirement, as it may be higher than the amount used // Binary search the gas requirement, as it may be higher than the amount used
var ( var (

View file

@ -86,6 +86,7 @@ type Backend interface {
CurrentBlock() *types.Block CurrentBlock() *types.Block
} }
// GetAPIs will return a map of the APIs
func GetAPIs(apiBackend Backend) []rpc.API { func GetAPIs(apiBackend Backend) []rpc.API {
nonceLock := new(AddrLocker) nonceLock := new(AddrLocker)
return []rpc.API{ return []rpc.API{