From d6a01768cf1cd673555fe04e6c1b9f0498b81991 Mon Sep 17 00:00:00 2001 From: Hugo Date: Thu, 22 Nov 2018 17:15:45 +0800 Subject: [PATCH] fix go vet problem --- .../consensus/tendermint/consensus_state.go | 2 +- plugin/consensus/tendermint/node.go | 20 +++++++++---------- plugin/consensus/tendermint/state.go | 2 +- plugin/consensus/tendermint/types/block.go | 1 - .../tendermint/types/height_vote_set.go | 1 - plugin/consensus/tendermint/types/util.go | 2 +- 6 files changed, 13 insertions(+), 15 deletions(-) diff --git a/plugin/consensus/tendermint/consensus_state.go b/plugin/consensus/tendermint/consensus_state.go index 9a4b0906dc..11a84093e0 100644 --- a/plugin/consensus/tendermint/consensus_state.go +++ b/plugin/consensus/tendermint/consensus_state.go @@ -862,7 +862,7 @@ func (cs *ConsensusState) enterPrecommit(height int64, round int) { // the latest POLRound should be this round polRound, _ := cs.Votes.POLInfo() if polRound < round { - panic(fmt.Sprintf("Panicked on a Sanity Check: %v", fmt.Sprintf("This POLRound should be %v but got %", round, polRound))) + panic(fmt.Sprintf("Panicked on a Sanity Check: %v", fmt.Sprintf("This POLRound should be %v but got %v", round, polRound))) } // +2/3 prevoted nil. Unlock and precommit nil. diff --git a/plugin/consensus/tendermint/node.go b/plugin/consensus/tendermint/node.go index ffd0ae4e14..49b3857d79 100644 --- a/plugin/consensus/tendermint/node.go +++ b/plugin/consensus/tendermint/node.go @@ -408,7 +408,7 @@ func (node *Node) addInboundPeer(conn net.Conn) error { // peer to the switch and to all registered reactors. // NOTE: This performs a blocking handshake before the peer is added. // NOTE: If error is returned, caller is responsible for calling peer.CloseConn() -func (node *Node) addPeer(pc peerConn) error { +func (node *Node) addPeer(pc *peerConn) error { addr := pc.conn.RemoteAddr() if err := node.FilterConnByAddr(addr); err != nil { return err @@ -472,7 +472,7 @@ func (node *Node) addPeer(pc peerConn) error { // All good. Start peer if node.IsRunning() { pc.SetTransferChannel(node.state.peerMsgQueue) - if err = node.startInitPeer(&pc); err != nil { + if err = node.startInitPeer(pc); err != nil { return err } } @@ -480,7 +480,7 @@ func (node *Node) addPeer(pc peerConn) error { // Add the peer to .peers. // We start it first so that a peer in the list is safe to Stop. // It should not err since we already checked peers.Has(). - if err := node.peerSet.Add(&pc); err != nil { + if err := node.peerSet.Add(pc); err != nil { return err } //node.metrics.Peers.Add(float64(1)) @@ -686,18 +686,18 @@ func dial(addr string) (net.Conn, error) { return conn, nil } -func newOutboundPeerConn(addr string, ourNodePrivKey crypto.PrivKey, onPeerError func(Peer, interface{}), state *ConsensusState, evpool *EvidencePool) (peerConn, error) { +func newOutboundPeerConn(addr string, ourNodePrivKey crypto.PrivKey, onPeerError func(Peer, interface{}), state *ConsensusState, evpool *EvidencePool) (*peerConn, error) { conn, err := dial(addr) if err != nil { - return peerConn{}, fmt.Errorf("Error creating peer:%v", err) + return &peerConn{}, fmt.Errorf("Error creating peer:%v", err) } pc, err := newPeerConn(conn, true, true, ourNodePrivKey, onPeerError, state, evpool) if err != nil { if cerr := conn.Close(); cerr != nil { - return peerConn{}, fmt.Errorf("newPeerConn failed:%v, connection close failed:%v", err, cerr) + return &peerConn{}, fmt.Errorf("newPeerConn failed:%v, connection close failed:%v", err, cerr) } - return peerConn{}, err + return &peerConn{}, err } return pc, nil @@ -709,7 +709,7 @@ func newInboundPeerConn( onPeerError func(Peer, interface{}), state *ConsensusState, evpool *EvidencePool, -) (peerConn, error) { +) (*peerConn, error) { // TODO: issue PoW challenge @@ -723,7 +723,7 @@ func newPeerConn( onPeerError func(Peer, interface{}), state *ConsensusState, evpool *EvidencePool, -) (pc peerConn, err error) { +) (pc *peerConn, err error) { conn := rawConn // Set deadline for secret handshake @@ -739,7 +739,7 @@ func newPeerConn( } // Only the information we already have - return peerConn{ + return &peerConn{ outbound: outbound, persistent: persistent, conn: conn, diff --git a/plugin/consensus/tendermint/state.go b/plugin/consensus/tendermint/state.go index 2af8eb9145..2d32547383 100644 --- a/plugin/consensus/tendermint/state.go +++ b/plugin/consensus/tendermint/state.go @@ -174,7 +174,7 @@ func MakeGenesisState(genDoc *ttypes.GenesisDoc) (State, error) { for i, val := range genDoc.Validators { pubKey, err := ttypes.PubKeyFromString(val.PubKey.Data) if err != nil { - return State{}, fmt.Errorf("Error validate[i] in genesis file: %v", i, err) + return State{}, fmt.Errorf("Error validate[%v] in genesis file: %v", i, err) } // Make validator diff --git a/plugin/consensus/tendermint/types/block.go b/plugin/consensus/tendermint/types/block.go index f8d30e9f8b..901589eebb 100644 --- a/plugin/consensus/tendermint/types/block.go +++ b/plugin/consensus/tendermint/types/block.go @@ -505,5 +505,4 @@ func (data *EvidenceData) StringIndented(indent string) string { %s}#%v`, indent, strings.Join(evStrings, "\n"+indent+" "), indent, data.hash) - return "" } diff --git a/plugin/consensus/tendermint/types/height_vote_set.go b/plugin/consensus/tendermint/types/height_vote_set.go index 03075a937e..4b040577fd 100644 --- a/plugin/consensus/tendermint/types/height_vote_set.go +++ b/plugin/consensus/tendermint/types/height_vote_set.go @@ -171,7 +171,6 @@ func (hvs *HeightVoteSet) getVoteSet(round int, type_ byte) *VoteSet { return rvs.Precommits default: panic(Fmt("Panicked on a Sanity Check: %v", Fmt("Unexpected vote type %X", type_))) - return nil } } diff --git a/plugin/consensus/tendermint/types/util.go b/plugin/consensus/tendermint/types/util.go index 25b95a899b..2baa0e8878 100644 --- a/plugin/consensus/tendermint/types/util.go +++ b/plugin/consensus/tendermint/types/util.go @@ -189,7 +189,7 @@ func PanicQ(v interface{}) { //--------------------BitArray------------------------ type BitArray struct { *tmtypes.TendermintBitArray - mtx sync.Mutex `json:"-"` + mtx sync.Mutex } // There is no BitArray whose Size is 0. Use nil instead.