From bc204f148d89c6139cd08dc6a3d3e036e989a0ca Mon Sep 17 00:00:00 2001 From: Trung Nguyen Date: Mon, 20 May 2019 11:23:12 -0400 Subject: [PATCH] run goimports --- cmd/geth/main.go | 3 ++- cmd/geth/usage.go | 2 +- cmd/utils/flags.go | 3 ++- common/types.go | 1 - consensus/istanbul/backend/backend.go | 4 +--- consensus/istanbul/backend/engine.go | 1 - core/genesis_test.go | 1 + core/quorum/api.go | 5 +++-- core/state/statedb_test.go | 2 +- core/state_transition.go | 2 +- core/types/permissions_cache.go | 5 +++-- core/types/transaction.go | 1 + core/vm/errors.go | 4 ++-- eth/handler_test.go | 8 ++++---- internal/ethapi/api.go | 3 ++- miner/miner.go | 2 +- permission/permission.go | 13 +++++++------ private/constellation/constellation.go | 8 ++++---- private/constellation/node.go | 3 ++- raft/handler.go | 2 +- raft/peer.go | 3 ++- 21 files changed, 41 insertions(+), 35 deletions(-) diff --git a/cmd/geth/main.go b/cmd/geth/main.go index bb9dcf037..ffa38742e 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -19,7 +19,6 @@ package main import ( "fmt" - "github.com/ethereum/go-ethereum/core/types" "math" "os" godebug "runtime/debug" @@ -28,6 +27,8 @@ import ( "strings" "time" + "github.com/ethereum/go-ethereum/core/types" + "github.com/elastic/gosigar" "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/accounts/keystore" diff --git a/cmd/geth/usage.go b/cmd/geth/usage.go index 40fe83acb..77bd38fb7 100644 --- a/cmd/geth/usage.go +++ b/cmd/geth/usage.go @@ -273,7 +273,7 @@ var AppHelpFlagGroups = []flagGroup{ }, { Name: "MISC", - },{ + }, { Name: "ISTANBUL", Flags: []cli.Flag{ utils.IstanbulRequestTimeoutFlag, diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index e9a1ed99b..3fde6f468 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -27,6 +27,8 @@ import ( "strconv" "strings" + "time" + "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/accounts/keystore" "github.com/ethereum/go-ethereum/common" @@ -57,7 +59,6 @@ import ( "github.com/ethereum/go-ethereum/params" whisper "github.com/ethereum/go-ethereum/whisper/whisperv6" "gopkg.in/urfave/cli.v1" - "time" ) var ( diff --git a/common/types.go b/common/types.go index 8efddb532..9c366ec88 100644 --- a/common/types.go +++ b/common/types.go @@ -175,7 +175,6 @@ func BytesToAddress(b []byte) Address { func StringToAddress(s string) Address { return BytesToAddress([]byte(s)) } // dep: Istanbul - // BigToAddress returns Address with byte values of b. // If b is larger than len(h), b will be cropped from the left. func BigToAddress(b *big.Int) Address { return BytesToAddress(b.Bytes()) } diff --git a/consensus/istanbul/backend/backend.go b/consensus/istanbul/backend/backend.go index bf9fb00a6..0676b8ef9 100644 --- a/consensus/istanbul/backend/backend.go +++ b/consensus/istanbul/backend/backend.go @@ -316,8 +316,6 @@ func (sb *backend) HasBadProposal(hash common.Hash) bool { return sb.hasBadBlock(hash) } - - func (sb *backend) Close() error { return nil -} \ No newline at end of file +} diff --git a/consensus/istanbul/backend/engine.go b/consensus/istanbul/backend/engine.go index 3fd681bd2..6e468f76e 100644 --- a/consensus/istanbul/backend/engine.go +++ b/consensus/istanbul/backend/engine.go @@ -616,7 +616,6 @@ func sigHash(header *types.Header) (hash common.Hash) { return hash } - // SealHash returns the hash of a block prior to it being sealed. func (sb *backend) SealHash(header *types.Header) common.Hash { return sigHash(header) diff --git a/core/genesis_test.go b/core/genesis_test.go index d353b3866..04b0bfcc5 100644 --- a/core/genesis_test.go +++ b/core/genesis_test.go @@ -24,6 +24,7 @@ import ( "github.com/davecgh/go-spew/spew" "github.com/ethereum/go-ethereum/common" + //"github.com/ethereum/go-ethereum/consensus/ethash" "github.com/ethereum/go-ethereum/core/rawdb" //"github.com/ethereum/go-ethereum/core/vm" diff --git a/core/quorum/api.go b/core/quorum/api.go index ac1b732aa..cdf4040e9 100644 --- a/core/quorum/api.go +++ b/core/quorum/api.go @@ -4,6 +4,9 @@ import ( "crypto/ecdsa" "errors" "fmt" + "math/big" + "regexp" + "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" @@ -14,8 +17,6 @@ import ( "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/p2p/enode" pbind "github.com/ethereum/go-ethereum/permission/bind" - "math/big" - "regexp" ) var isStringAlphaNumeric = regexp.MustCompile(`^[a-zA-Z0-9_-]*$`).MatchString diff --git a/core/state/statedb_test.go b/core/state/statedb_test.go index f7586b70d..db4a72132 100644 --- a/core/state/statedb_test.go +++ b/core/state/statedb_test.go @@ -119,7 +119,7 @@ func TestIntermediateLeaks(t *testing.T) { func TestStorageRoot(t *testing.T) { var ( - mem = ethdb.NewMemDatabase() + mem = ethdb.NewMemDatabase() db = NewDatabase(mem) state, _ = New(common.Hash{}, db) addr = common.Address{1} diff --git a/core/state_transition.go b/core/state_transition.go index 89166dda0..ebad3391f 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -231,7 +231,7 @@ func (st *StateTransition) TransitionDb() (ret []byte, usedGas uint64, failed bo var ( leftoverGas uint64 - evm = st.evm + evm = st.evm // vm errors do not effect consensus and are therefor // not assigned to err, except for insufficient balance // error. diff --git a/core/types/permissions_cache.go b/core/types/permissions_cache.go index de33eec91..998ec0ed5 100644 --- a/core/types/permissions_cache.go +++ b/core/types/permissions_cache.go @@ -1,11 +1,12 @@ package types import ( - "github.com/ethereum/go-ethereum/common" - "github.com/hashicorp/golang-lru" "math/big" "strings" "sync" + + "github.com/ethereum/go-ethereum/common" + "github.com/hashicorp/golang-lru" ) type AccessType uint8 diff --git a/core/types/transaction.go b/core/types/transaction.go index f79ce9d9a..4a74f71d3 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -24,6 +24,7 @@ import ( "sync/atomic" fmt "fmt" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/crypto" diff --git a/core/vm/errors.go b/core/vm/errors.go index 66f9c5e46..771fde022 100644 --- a/core/vm/errors.go +++ b/core/vm/errors.go @@ -26,6 +26,6 @@ var ( ErrInsufficientBalance = errors.New("insufficient balance for transfer") ErrContractAddressCollision = errors.New("contract address collision") - ErrReadOnlyValueTransfer = errors.New("VM in read-only mode. Value transfer prohibited.") - ErrNoCompatibleInterpreter = errors.New("no compatible interpreter") + ErrReadOnlyValueTransfer = errors.New("VM in read-only mode. Value transfer prohibited.") + ErrNoCompatibleInterpreter = errors.New("no compatible interpreter") ) diff --git a/eth/handler_test.go b/eth/handler_test.go index 5fe16bedc..3ecb13b94 100644 --- a/eth/handler_test.go +++ b/eth/handler_test.go @@ -246,10 +246,10 @@ func testGetBlockBodies(t *testing.T, protocol int) { available []bool // Availability of explicitly requested blocks expected int // Total number of existing blocks to expect }{ - {1, nil, nil, 1}, // A single random block should be retrievable - {10, nil, nil, 10}, // Multiple random blocks should be retrievable - {limit, nil, nil, limit}, // The maximum possible blocks should be retrievable - {limit + 1, nil, nil, limit}, // No more than the possible block count should be returned + {1, nil, nil, 1}, // A single random block should be retrievable + {10, nil, nil, 10}, // Multiple random blocks should be retrievable + {limit, nil, nil, limit}, // The maximum possible blocks should be retrievable + {limit + 1, nil, nil, limit}, // No more than the possible block count should be returned {0, []common.Hash{pm.blockchain.Genesis().Hash()}, []bool{true}, 1}, // The genesis block should be retrievable {0, []common.Hash{pm.blockchain.CurrentBlock().Hash()}, []bool{true}, 1}, // The chains head block should be retrievable {0, []common.Hash{{}}, []bool{false}, 0}, // A non existent block should not be returned diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index 8ae253bc9..a05bf01d9 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -29,9 +29,10 @@ import ( "encoding/json" "net/http" - "github.com/davecgh/go-spew/spew" "sync" + "github.com/davecgh/go-spew/spew" + "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/accounts/keystore" "github.com/ethereum/go-ethereum/common" diff --git a/miner/miner.go b/miner/miner.go index 41d69f9bc..565df529c 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -28,10 +28,10 @@ import ( "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/eth/downloader" + "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" - "github.com/ethereum/go-ethereum/ethdb" ) // Backend wraps all methods required for mining. diff --git a/permission/permission.go b/permission/permission.go index 75880ffdf..bb71e089d 100644 --- a/permission/permission.go +++ b/permission/permission.go @@ -4,6 +4,13 @@ import ( "crypto/ecdsa" "encoding/json" "errors" + "io/ioutil" + "math/big" + "os" + "path/filepath" + "sync" + "time" + "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" @@ -16,12 +23,6 @@ import ( "github.com/ethereum/go-ethereum/params" pbind "github.com/ethereum/go-ethereum/permission/bind" "github.com/ethereum/go-ethereum/raft" - "io/ioutil" - "math/big" - "os" - "path/filepath" - "sync" - "time" ) type NodeOperation uint8 diff --git a/private/constellation/constellation.go b/private/constellation/constellation.go index a16c9c841..4b7a6e1d2 100644 --- a/private/constellation/constellation.go +++ b/private/constellation/constellation.go @@ -89,8 +89,8 @@ func New(path string) (*Constellation, error) { return nil, err } return &Constellation{ - node: n, - c: cache.New(5*time.Minute, 5*time.Minute), + node: n, + c: cache.New(5*time.Minute, 5*time.Minute), isConstellationNotInUse: false, }, nil } @@ -98,8 +98,8 @@ func New(path string) (*Constellation, error) { func MustNew(path string) *Constellation { if strings.EqualFold(path, "ignore") { return &Constellation{ - node: nil, - c: nil, + node: nil, + c: nil, isConstellationNotInUse: true, } } diff --git a/private/constellation/node.go b/private/constellation/node.go index 50263aae6..50c7ed566 100644 --- a/private/constellation/node.go +++ b/private/constellation/node.go @@ -6,7 +6,6 @@ import ( "encoding/json" "errors" "fmt" - "github.com/tv42/httpunix" "io" "io/ioutil" "net/http" @@ -14,6 +13,8 @@ import ( "os/exec" "strings" "time" + + "github.com/tv42/httpunix" ) func launchNode(cfgPath string) (*exec.Cmd, error) { diff --git a/raft/handler.go b/raft/handler.go index 966ce6596..7625b2bbb 100755 --- a/raft/handler.go +++ b/raft/handler.go @@ -765,7 +765,7 @@ func (pm *ProtocolManager) eventLoop() { case raftpb.ConfChangeAddNode: if pm.isRaftIdRemoved(raftId) { log.Info("ignoring ConfChangeAddNode for permanently-removed peer", "raft id", raftId) - } else if peer := pm.peers[raftId]; peer != nil && raftId <= uint16(len(pm.bootstrapNodes)) { + } else if peer := pm.peers[raftId]; peer != nil && raftId <= uint16(len(pm.bootstrapNodes)) { // See initial cluster logic in startRaft() for more information. log.Info("ignoring expected ConfChangeAddNode for initial peer", "raft id", raftId) diff --git a/raft/peer.go b/raft/peer.go index 064923910..61fd73ad2 100644 --- a/raft/peer.go +++ b/raft/peer.go @@ -5,10 +5,11 @@ import ( "net" "fmt" + "log" + "github.com/ethereum/go-ethereum/p2p/enode" "github.com/ethereum/go-ethereum/p2p/enr" "github.com/ethereum/go-ethereum/rlp" - "log" ) // Serializable information about a Peer. Sufficient to build `etcdRaft.Peer`