From 5596b63846edd2ec9237d4e9c666d6982cff29cf Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Fri, 18 May 2018 18:55:52 -0700 Subject: [PATCH] multi: fix linter warnings --- mempool/mempool.go | 2 +- peer/peer.go | 5 ++++- rpcserverhelp.go | 6 +++--- wire/msgcfcheckpt.go | 4 +++- wire/msgcfheaders.go | 2 +- wire/msggetcfcheckpt.go | 17 +++-------------- wire/msggetcfheaders.go | 14 ++------------ wire/msggetcfilters.go | 14 ++------------ 8 files changed, 19 insertions(+), 45 deletions(-) diff --git a/mempool/mempool.go b/mempool/mempool.go index 91dbb6de..d4088fc7 100644 --- a/mempool/mempool.go +++ b/mempool/mempool.go @@ -571,7 +571,7 @@ func (mp *TxPool) checkPoolDoubleSpend(tx *btcutil.Tx) error { return nil } -// CheckSpends checks whether the passed outpoint is already spent by a +// CheckSpend checks whether the passed outpoint is already spent by a // transaction in the mempool. If that's the case the spending transaction will // be returned, if not nil will be returned. func (mp *TxPool) CheckSpend(op wire.OutPoint) *btcutil.Tx { diff --git a/peer/peer.go b/peer/peer.go index 64a6e759..9aecab59 100644 --- a/peer/peer.go +++ b/peer/peer.go @@ -1286,6 +1286,10 @@ func (p *Peer) maybeAddDeadline(pendingResponses map[string]time.Time, msgCmd st // Expects an inv message. pendingResponses[wire.CmdInv] = deadline + case wire.CmdGetBlocks: + // Expects an inv message. + pendingResponses[wire.CmdInv] = deadline + case wire.CmdGetData: // Expects a block, merkleblock, tx, or notfound message. pendingResponses[wire.CmdBlock] = deadline @@ -1409,7 +1413,6 @@ out: continue } - continue log.Debugf("Peer %s appears to be stalled or "+ "misbehaving, %s timeout -- "+ "disconnecting", p, command) diff --git a/rpcserverhelp.go b/rpcserverhelp.go index c22448e1..46d05a4d 100644 --- a/rpcserverhelp.go +++ b/rpcserverhelp.go @@ -333,9 +333,9 @@ var helpDescsEnUS = map[string]string{ "getblocktemplate--result1": "An error string which represents why the proposal was rejected or nothing if accepted", // GetCFilterCmd help. - "getcfilter--synopsis": "Returns a block's committed filter given its hash.", - "getcfilter-hash": "The hash of the block", - "getcfilter--result0": "The block's committed filter", + "getcfilter--synopsis": "Returns a block's committed filter given its hash.", + "getcfilter-hash": "The hash of the block", + "getcfilter--result0": "The block's committed filter", // GetConnectionCountCmd help. "getconnectioncount--synopsis": "Returns the number of active connections to other peers.", diff --git a/wire/msgcfcheckpt.go b/wire/msgcfcheckpt.go index cdf32dd5..32f9575e 100644 --- a/wire/msgcfcheckpt.go +++ b/wire/msgcfcheckpt.go @@ -12,6 +12,8 @@ import ( ) const ( + // CFCheckptInterval is the gap (in number of blocks) between each + // filter header checkpoint. CFCheckptInterval = 1000 ) @@ -60,7 +62,7 @@ func (msg *MsgCFCheckpt) BtcDecode(r io.Reader, pver uint32, _ MessageEncoding) // Create a contiguous slice of hashes to deserialize into in order to // reduce the number of allocations. - msg.FilterHeaders = make([]*chainhash.Hash, count, count) + msg.FilterHeaders = make([]*chainhash.Hash, count) for i := uint64(0); i < count; i++ { var cfh chainhash.Hash err := readElement(r, &cfh) diff --git a/wire/msgcfheaders.go b/wire/msgcfheaders.go index a3572807..40d30f9b 100644 --- a/wire/msgcfheaders.go +++ b/wire/msgcfheaders.go @@ -33,7 +33,7 @@ type MsgCFHeaders struct { FilterHashes []*chainhash.Hash } -// AddCFHeader adds a new committed filter header to the message. +// AddCFHash adds a new filter hash to the message. func (msg *MsgCFHeaders) AddCFHash(hash *chainhash.Hash) error { if len(msg.FilterHashes)+1 > MaxCFHeadersPerMsg { str := fmt.Sprintf("too many block headers in message [max %v]", diff --git a/wire/msggetcfcheckpt.go b/wire/msggetcfcheckpt.go index 60ec2652..c30a86ce 100644 --- a/wire/msggetcfcheckpt.go +++ b/wire/msggetcfcheckpt.go @@ -26,12 +26,7 @@ func (msg *MsgGetCFCheckpt) BtcDecode(r io.Reader, pver uint32, _ MessageEncodin return err } - err = readElement(r, &msg.StopHash) - if err != nil { - return err - } - - return nil + return readElement(r, &msg.StopHash) } // BtcEncode encodes the receiver to w using the bitcoin protocol encoding. @@ -42,12 +37,7 @@ func (msg *MsgGetCFCheckpt) BtcEncode(w io.Writer, pver uint32, _ MessageEncodin return err } - err = writeElement(w, &msg.StopHash) - if err != nil { - return err - } - - return nil + return writeElement(w, &msg.StopHash) } // Command returns the protocol command string for the message. This is part @@ -66,8 +56,7 @@ func (msg *MsgGetCFCheckpt) MaxPayloadLength(pver uint32) uint32 { // NewMsgGetCFCheckpt returns a new bitcoin getcfcheckpt message that conforms // to the Message interface using the passed parameters and defaults for the // remaining fields. -func NewMsgGetCFCheckpt(filterType FilterType, stopHash *chainhash.Hash, -) *MsgGetCFCheckpt { +func NewMsgGetCFCheckpt(filterType FilterType, stopHash *chainhash.Hash) *MsgGetCFCheckpt { return &MsgGetCFCheckpt{ FilterType: filterType, StopHash: *stopHash, diff --git a/wire/msggetcfheaders.go b/wire/msggetcfheaders.go index d7928643..03a1caf7 100644 --- a/wire/msggetcfheaders.go +++ b/wire/msggetcfheaders.go @@ -32,12 +32,7 @@ func (msg *MsgGetCFHeaders) BtcDecode(r io.Reader, pver uint32, _ MessageEncodin return err } - err = readElement(r, &msg.StopHash) - if err != nil { - return err - } - - return nil + return readElement(r, &msg.StopHash) } // BtcEncode encodes the receiver to w using the bitcoin protocol encoding. @@ -53,12 +48,7 @@ func (msg *MsgGetCFHeaders) BtcEncode(w io.Writer, pver uint32, _ MessageEncodin return err } - err = writeElement(w, &msg.StopHash) - if err != nil { - return err - } - - return nil + return writeElement(w, &msg.StopHash) } // Command returns the protocol command string for the message. This is part diff --git a/wire/msggetcfilters.go b/wire/msggetcfilters.go index 7818bf15..80024138 100644 --- a/wire/msggetcfilters.go +++ b/wire/msggetcfilters.go @@ -36,12 +36,7 @@ func (msg *MsgGetCFilters) BtcDecode(r io.Reader, pver uint32, _ MessageEncoding return err } - err = readElement(r, &msg.StopHash) - if err != nil { - return err - } - - return nil + return readElement(r, &msg.StopHash) } // BtcEncode encodes the receiver to w using the bitcoin protocol encoding. @@ -57,12 +52,7 @@ func (msg *MsgGetCFilters) BtcEncode(w io.Writer, pver uint32, _ MessageEncoding return err } - err = writeElement(w, &msg.StopHash) - if err != nil { - return err - } - - return nil + return writeElement(w, &msg.StopHash) } // Command returns the protocol command string for the message. This is part