Skip to content

Commit

Permalink
Correct a few style related issues found by golint.
Browse files Browse the repository at this point in the history
Upstream commit 5a9bac9
  • Loading branch information
davecgh committed May 19, 2016
2 parents 9798cde + 5a9bac9 commit 0c883ff
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion chaincfg/chainhash/hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"fmt"
)

// HashSize of array used to store sha hashes. See Hash.
// HashSize of array used to store hashes. See Hash.
const HashSize = 32

// MaxHashStringSize is the maximum length of a Hash hash string.
Expand Down
2 changes: 1 addition & 1 deletion goclean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ set -ex
# Automatic checks
test -z "$(gofmt -l -w . | tee /dev/stderr)"
test -z "$(goimports -l -w . | tee /dev/stderr)"
test -z "$(golint ./... | grep -v 'ALL_CAPS\|OP_\|NewFieldVal\|Id\|RpcCommand\|RpcRawCommand\|RpcSend\|Dns' | tee /dev/stderr)"
test -z "$(golint ./... | grep -v 'ALL_CAPS\|OP_\|NewFieldVal\|RpcCommand\|RpcRawCommand\|RpcSend\|Dns' | tee /dev/stderr)"
test -z "$(go tool vet . 2>&1 | grep -v 'Example\|newestSha' | tee /dev/stderr)"
env GORACE="halt_on_error=1" go test -v -race ./...

Expand Down
18 changes: 9 additions & 9 deletions rpcserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,15 +445,15 @@ func handleNode(s *rpcServer, cmd interface{}, closeChan <-chan struct{}) (inter
c := cmd.(*dcrjson.NodeCmd)

var addr string
var nodeId uint64
var nodeID uint64
var errN, err error
switch c.SubCmd {
case "disconnect":
// If we have a valid uint disconnect by node id. Otherwise,
// attempt to disconnect by address, returning an error if a
// valid IP address is not supplied.
if nodeId, errN = strconv.ParseUint(c.Target, 10, 32); errN == nil {
err = s.server.DisconnectNodeById(int32(nodeId))
if nodeID, errN = strconv.ParseUint(c.Target, 10, 32); errN == nil {
err = s.server.DisconnectNodeByID(int32(nodeID))
} else {
if _, _, errP := net.SplitHostPort(c.Target); errP == nil || net.ParseIP(c.Target) != nil {
addr = normalizeAddress(c.Target, activeNetParams.DefaultPort)
Expand All @@ -465,7 +465,7 @@ func handleNode(s *rpcServer, cmd interface{}, closeChan <-chan struct{}) (inter
}
}
}
if err != nil && peerExists(s.server.PeerInfo(), addr, int32(nodeId)) {
if err != nil && peerExists(s.server.PeerInfo(), addr, int32(nodeID)) {
return nil, &dcrjson.RPCError{
Code: dcrjson.ErrRPCMisc,
Message: "can't disconnect a permanent peer, use remove",
Expand All @@ -475,8 +475,8 @@ func handleNode(s *rpcServer, cmd interface{}, closeChan <-chan struct{}) (inter
// If we have a valid uint disconnect by node id. Otherwise,
// attempt to disconnect by address, returning an error if a
// valid IP address is not supplied.
if nodeId, errN = strconv.ParseUint(c.Target, 10, 32); errN == nil {
err = s.server.RemoveNodeById(int32(nodeId))
if nodeID, errN = strconv.ParseUint(c.Target, 10, 32); errN == nil {
err = s.server.RemoveNodeByID(int32(nodeID))
} else {
if _, _, errP := net.SplitHostPort(c.Target); errP == nil || net.ParseIP(c.Target) != nil {
addr = normalizeAddress(c.Target, activeNetParams.DefaultPort)
Expand All @@ -488,7 +488,7 @@ func handleNode(s *rpcServer, cmd interface{}, closeChan <-chan struct{}) (inter
}
}
}
if err != nil && peerExists(s.server.PeerInfo(), addr, int32(nodeId)) {
if err != nil && peerExists(s.server.PeerInfo(), addr, int32(nodeID)) {
return nil, &dcrjson.RPCError{
Code: dcrjson.ErrRPCMisc,
Message: "can't remove a temporary peer, use disconnect",
Expand Down Expand Up @@ -533,9 +533,9 @@ func handleNode(s *rpcServer, cmd interface{}, closeChan <-chan struct{}) (inter
// peerExists determines if a certain peer is currently connected given
// information about all currently connected peers. Peer existence is
// determined using either a target address or node id.
func peerExists(peerInfos []*dcrjson.GetPeerInfoResult, addr string, nodeId int32) bool {
func peerExists(peerInfos []*dcrjson.GetPeerInfoResult, addr string, nodeID int32) bool {
for _, peerInfo := range peerInfos {
if peerInfo.ID == nodeId || peerInfo.Addr == addr {
if peerInfo.ID == nodeID || peerInfo.Addr == addr {
return true
}
}
Expand Down
6 changes: 3 additions & 3 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ func (s *server) DisconnectNodeByAddr(addr string) error {
// DisconnectNodeByID disconnects a peer by target node id. Both outbound and
// inbound nodes will be searched for the target node. An error message will be
// returned if the peer was not found.
func (s *server) DisconnectNodeById(id int32) error {
func (s *server) DisconnectNodeByID(id int32) error {
replyChan := make(chan error)

s.query <- disconnectNodeMsg{
Expand All @@ -933,9 +933,9 @@ func (s *server) RemoveNodeByAddr(addr string) error {
return <-replyChan
}

// RemoveNodeById removes a peer by node ID from the list of persistent peers
// RemoveNodeByID removes a peer by node ID from the list of persistent peers
// if present. An error will be returned if the peer was not found.
func (s *server) RemoveNodeById(id int32) error {
func (s *server) RemoveNodeByID(id int32) error {
replyChan := make(chan error)

s.query <- removeNodeMsg{
Expand Down
2 changes: 1 addition & 1 deletion wire/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"github.com/decred/dcrd/chaincfg/chainhash"
)

// MaxVarIntPayload payload size for a variable length integer.
// MaxVarIntPayload is the maximum payload size for a variable length integer.
const MaxVarIntPayload = 9

// errNonCanonicalVarInt is the common format string used for non-canonically
Expand Down

0 comments on commit 0c883ff

Please sign in to comment.