Commit 9a70e5fd authored by Hugo's avatar Hugo

fix go vet problem

parent 5d10cc15
...@@ -862,7 +862,7 @@ func (cs *ConsensusState) enterPrecommit(height int64, round int) { ...@@ -862,7 +862,7 @@ func (cs *ConsensusState) enterPrecommit(height int64, round int) {
// the latest POLRound should be this round // the latest POLRound should be this round
polRound, _ := cs.Votes.POLInfo() polRound, _ := cs.Votes.POLInfo()
if polRound < round { 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. // +2/3 prevoted nil. Unlock and precommit nil.
......
...@@ -408,7 +408,7 @@ func (node *Node) addInboundPeer(conn net.Conn) error { ...@@ -408,7 +408,7 @@ func (node *Node) addInboundPeer(conn net.Conn) error {
// peer to the switch and to all registered reactors. // peer to the switch and to all registered reactors.
// NOTE: This performs a blocking handshake before the peer is added. // NOTE: This performs a blocking handshake before the peer is added.
// NOTE: If error is returned, caller is responsible for calling peer.CloseConn() // 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() addr := pc.conn.RemoteAddr()
if err := node.FilterConnByAddr(addr); err != nil { if err := node.FilterConnByAddr(addr); err != nil {
return err return err
...@@ -472,7 +472,7 @@ func (node *Node) addPeer(pc peerConn) error { ...@@ -472,7 +472,7 @@ func (node *Node) addPeer(pc peerConn) error {
// All good. Start peer // All good. Start peer
if node.IsRunning() { if node.IsRunning() {
pc.SetTransferChannel(node.state.peerMsgQueue) pc.SetTransferChannel(node.state.peerMsgQueue)
if err = node.startInitPeer(&pc); err != nil { if err = node.startInitPeer(pc); err != nil {
return err return err
} }
} }
...@@ -480,7 +480,7 @@ func (node *Node) addPeer(pc peerConn) error { ...@@ -480,7 +480,7 @@ func (node *Node) addPeer(pc peerConn) error {
// Add the peer to .peers. // Add the peer to .peers.
// We start it first so that a peer in the list is safe to Stop. // 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(). // 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 return err
} }
//node.metrics.Peers.Add(float64(1)) //node.metrics.Peers.Add(float64(1))
...@@ -686,18 +686,18 @@ func dial(addr string) (net.Conn, error) { ...@@ -686,18 +686,18 @@ func dial(addr string) (net.Conn, error) {
return conn, nil 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) conn, err := dial(addr)
if err != nil { 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) pc, err := newPeerConn(conn, true, true, ourNodePrivKey, onPeerError, state, evpool)
if err != nil { if err != nil {
if cerr := conn.Close(); cerr != 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 return pc, nil
...@@ -709,7 +709,7 @@ func newInboundPeerConn( ...@@ -709,7 +709,7 @@ func newInboundPeerConn(
onPeerError func(Peer, interface{}), onPeerError func(Peer, interface{}),
state *ConsensusState, state *ConsensusState,
evpool *EvidencePool, evpool *EvidencePool,
) (peerConn, error) { ) (*peerConn, error) {
// TODO: issue PoW challenge // TODO: issue PoW challenge
...@@ -723,7 +723,7 @@ func newPeerConn( ...@@ -723,7 +723,7 @@ func newPeerConn(
onPeerError func(Peer, interface{}), onPeerError func(Peer, interface{}),
state *ConsensusState, state *ConsensusState,
evpool *EvidencePool, evpool *EvidencePool,
) (pc peerConn, err error) { ) (pc *peerConn, err error) {
conn := rawConn conn := rawConn
// Set deadline for secret handshake // Set deadline for secret handshake
...@@ -739,7 +739,7 @@ func newPeerConn( ...@@ -739,7 +739,7 @@ func newPeerConn(
} }
// Only the information we already have // Only the information we already have
return peerConn{ return &peerConn{
outbound: outbound, outbound: outbound,
persistent: persistent, persistent: persistent,
conn: conn, conn: conn,
......
...@@ -174,7 +174,7 @@ func MakeGenesisState(genDoc *ttypes.GenesisDoc) (State, error) { ...@@ -174,7 +174,7 @@ func MakeGenesisState(genDoc *ttypes.GenesisDoc) (State, error) {
for i, val := range genDoc.Validators { for i, val := range genDoc.Validators {
pubKey, err := ttypes.PubKeyFromString(val.PubKey.Data) pubKey, err := ttypes.PubKeyFromString(val.PubKey.Data)
if err != nil { 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 // Make validator
......
...@@ -505,5 +505,4 @@ func (data *EvidenceData) StringIndented(indent string) string { ...@@ -505,5 +505,4 @@ func (data *EvidenceData) StringIndented(indent string) string {
%s}#%v`, %s}#%v`,
indent, strings.Join(evStrings, "\n"+indent+" "), indent, strings.Join(evStrings, "\n"+indent+" "),
indent, data.hash) indent, data.hash)
return ""
} }
...@@ -171,7 +171,6 @@ func (hvs *HeightVoteSet) getVoteSet(round int, type_ byte) *VoteSet { ...@@ -171,7 +171,6 @@ func (hvs *HeightVoteSet) getVoteSet(round int, type_ byte) *VoteSet {
return rvs.Precommits return rvs.Precommits
default: default:
panic(Fmt("Panicked on a Sanity Check: %v", Fmt("Unexpected vote type %X", type_))) panic(Fmt("Panicked on a Sanity Check: %v", Fmt("Unexpected vote type %X", type_)))
return nil
} }
} }
......
...@@ -189,7 +189,7 @@ func PanicQ(v interface{}) { ...@@ -189,7 +189,7 @@ func PanicQ(v interface{}) {
//--------------------BitArray------------------------ //--------------------BitArray------------------------
type BitArray struct { type BitArray struct {
*tmtypes.TendermintBitArray *tmtypes.TendermintBitArray
mtx sync.Mutex `json:"-"` mtx sync.Mutex
} }
// There is no BitArray whose Size is 0. Use nil instead. // There is no BitArray whose Size is 0. Use nil instead.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment