From 01cb59c67dce0fdfb963f5560fab9a7d387a246a Mon Sep 17 00:00:00 2001 From: Dave Collins Date: Sat, 1 Jul 2017 02:23:25 -0500 Subject: [PATCH] multi: Simplify code per gosimple linter. This simplifies the code based on the recommendations of the gosimple lint tool. --- blockchain/chain.go | 2 -- blockchain/reorganization_test.go | 2 -- blockchain/utxoviewpoint.go | 2 -- btcjson/cmdparse.go | 2 +- database/ffldb/blockio.go | 1 - peer/mruinvmap.go | 1 - peer/mrunoncemap.go | 1 - wire/msgaddr_test.go | 2 -- wire/msgblock_test.go | 2 -- wire/msgfeefilter_test.go | 2 -- wire/msgfilteradd_test.go | 2 -- wire/msgfilterclear_test.go | 2 -- wire/msgfilterload_test.go | 2 -- wire/msggetaddr_test.go | 2 -- wire/msggetblocks_test.go | 2 -- wire/msggetdata_test.go | 2 -- wire/msggetheaders_test.go | 2 -- wire/msgheaders_test.go | 2 -- wire/msginv_test.go | 2 -- wire/msgmempool_test.go | 2 -- wire/msgnotfound_test.go | 2 -- wire/msgping_test.go | 4 ---- wire/msgpong_test.go | 4 ---- wire/msgsendheaders_test.go | 4 ---- wire/msgtx_test.go | 2 -- wire/msgverack_test.go | 2 -- wire/msgversion_test.go | 2 -- 27 files changed, 1 insertion(+), 56 deletions(-) diff --git a/blockchain/chain.go b/blockchain/chain.go index e53d3f3650..4969842f2b 100644 --- a/blockchain/chain.go +++ b/blockchain/chain.go @@ -321,8 +321,6 @@ func (b *BlockChain) addOrphanBlock(block *btcutil.Block) { // Add to previous hash lookup index for faster dependency lookups. prevHash := &block.MsgBlock().Header.PrevBlock b.prevOrphans[*prevHash] = append(b.prevOrphans[*prevHash], oBlock) - - return } // SequenceLock represents the converted relative lock-time in seconds, and diff --git a/blockchain/reorganization_test.go b/blockchain/reorganization_test.go index 3e0194bdb4..4c1f21af1f 100644 --- a/blockchain/reorganization_test.go +++ b/blockchain/reorganization_test.go @@ -68,8 +68,6 @@ func TestReorganization(t *testing.T) { "is an orphan\n", i) } } - - return } // loadBlocks reads files containing bitcoin block data (gzipped but otherwise diff --git a/blockchain/utxoviewpoint.go b/blockchain/utxoviewpoint.go index e16ffbdd04..f3d45cbb30 100644 --- a/blockchain/utxoviewpoint.go +++ b/blockchain/utxoviewpoint.go @@ -105,7 +105,6 @@ func (entry *UtxoEntry) SpendOutput(outputIndex uint32) { entry.modified = true output.spent = true - return } // IsFullySpent returns whether or not the transaction the utxo entry represents @@ -269,7 +268,6 @@ func (view *UtxoViewpoint) AddTxOuts(tx *btcutil.Tx, blockHeight int32) { pkScript: txOut.PkScript, } } - return } // connectTransaction updates the view by adding all new utxos created by the diff --git a/btcjson/cmdparse.go b/btcjson/cmdparse.go index 6e21b94611..abe52e3662 100644 --- a/btcjson/cmdparse.go +++ b/btcjson/cmdparse.go @@ -49,7 +49,7 @@ func MarshalCmd(id interface{}, cmd interface{}) ([]byte, error) { // The provided command must not be nil. rv := reflect.ValueOf(cmd) if rv.IsNil() { - str := fmt.Sprint("the specified command is nil") + str := "the specified command is nil" return nil, makeError(ErrInvalidType, str) } diff --git a/database/ffldb/blockio.go b/database/ffldb/blockio.go index bfbdbe14c8..3d7782f93c 100644 --- a/database/ffldb/blockio.go +++ b/database/ffldb/blockio.go @@ -710,7 +710,6 @@ func (s *blockStore) handleRollback(oldBlockFileNum, oldBlockOffset uint32) { wc.curFileNum, err) return } - return } // scanBlockFiles searches the database directory for all flat block files to diff --git a/peer/mruinvmap.go b/peer/mruinvmap.go index ecbfc042f7..0bf1b2b34a 100644 --- a/peer/mruinvmap.go +++ b/peer/mruinvmap.go @@ -99,7 +99,6 @@ func (m *mruInventoryMap) Add(iv *wire.InvVect) { // The limit hasn't been reached yet, so just add the new item. node := m.invList.PushFront(iv) m.invMap[*iv] = node - return } // Delete deletes the passed inventory item from the map (if it exists). diff --git a/peer/mrunoncemap.go b/peer/mrunoncemap.go index a830e7a2b6..5f7c798429 100644 --- a/peer/mrunoncemap.go +++ b/peer/mrunoncemap.go @@ -97,7 +97,6 @@ func (m *mruNonceMap) Add(nonce uint64) { // The limit hasn't been reached yet, so just add the new item. node := m.nonceList.PushFront(nonce) m.nonceMap[nonce] = node - return } // Delete deletes the passed nonce from the map (if it exists). diff --git a/wire/msgaddr_test.go b/wire/msgaddr_test.go index 649cd8af6f..fc466e034b 100644 --- a/wire/msgaddr_test.go +++ b/wire/msgaddr_test.go @@ -95,8 +95,6 @@ func TestAddr(t *testing.T) { "protocol version %d - got %v, want %v", pver, maxPayload, wantPayload) } - - return } // TestAddrWire tests the MsgAddr wire encode and decode for various numbers diff --git a/wire/msgblock_test.go b/wire/msgblock_test.go index 9c07e0c39b..b861ff51f2 100644 --- a/wire/msgblock_test.go +++ b/wire/msgblock_test.go @@ -65,8 +65,6 @@ func TestBlock(t *testing.T) { t.Errorf("ClearTransactions: wrong transactions - got %v, want %v", len(msg.Transactions), 0) } - - return } // TestBlockTxHashes tests the ability to generate a slice of all transaction diff --git a/wire/msgfeefilter_test.go b/wire/msgfeefilter_test.go index 3159bfcb21..029462406e 100644 --- a/wire/msgfeefilter_test.go +++ b/wire/msgfeefilter_test.go @@ -59,8 +59,6 @@ func TestFeeFilterLatest(t *testing.T) { if msg.MinFee != readmsg.MinFee { t.Errorf("Should get same minfee for protocol version %d", pver) } - - return } // TestFeeFilterWire tests the MsgFeeFilter wire encode and decode for various protocol diff --git a/wire/msgfilteradd_test.go b/wire/msgfilteradd_test.go index e8efe690c1..67144301d0 100644 --- a/wire/msgfilteradd_test.go +++ b/wire/msgfilteradd_test.go @@ -48,8 +48,6 @@ func TestFilterAddLatest(t *testing.T) { if err != nil { t.Errorf("decode of MsgFilterAdd failed [%v] err <%v>", buf, err) } - - return } // TestFilterAddCrossProtocol tests the MsgFilterAdd API when encoding with the diff --git a/wire/msgfilterclear_test.go b/wire/msgfilterclear_test.go index 45c96af85c..8e4c60028d 100644 --- a/wire/msgfilterclear_test.go +++ b/wire/msgfilterclear_test.go @@ -34,8 +34,6 @@ func TestFilterClearLatest(t *testing.T) { "protocol version %d - got %v, want %v", pver, maxPayload, wantPayload) } - - return } // TestFilterClearCrossProtocol tests the MsgFilterClear API when encoding with diff --git a/wire/msgfilterload_test.go b/wire/msgfilterload_test.go index 6396d502e2..bfa7a4fe9b 100644 --- a/wire/msgfilterload_test.go +++ b/wire/msgfilterload_test.go @@ -48,8 +48,6 @@ func TestFilterLoadLatest(t *testing.T) { if err != nil { t.Errorf("decode of MsgFilterLoad failed [%v] err <%v>", buf, err) } - - return } // TestFilterLoadCrossProtocol tests the MsgFilterLoad API when encoding with diff --git a/wire/msggetaddr_test.go b/wire/msggetaddr_test.go index a46d59508b..a5427322dc 100644 --- a/wire/msggetaddr_test.go +++ b/wire/msggetaddr_test.go @@ -33,8 +33,6 @@ func TestGetAddr(t *testing.T) { "protocol version %d - got %v, want %v", pver, maxPayload, wantPayload) } - - return } // TestGetAddrWire tests the MsgGetAddr wire encode and decode for various diff --git a/wire/msggetblocks_test.go b/wire/msggetblocks_test.go index b957b60e30..c75682592e 100644 --- a/wire/msggetblocks_test.go +++ b/wire/msggetblocks_test.go @@ -78,8 +78,6 @@ func TestGetBlocks(t *testing.T) { t.Errorf("AddBlockLocatorHash: expected error on too many " + "block locator hashes not received") } - - return } // TestGetBlocksWire tests the MsgGetBlocks wire encode and decode for various diff --git a/wire/msggetdata_test.go b/wire/msggetdata_test.go index 0d7fc663cb..a4bf182712 100644 --- a/wire/msggetdata_test.go +++ b/wire/msggetdata_test.go @@ -66,8 +66,6 @@ func TestGetData(t *testing.T) { t.Errorf("NewMsgGetDataSizeHint: wrong cap for size hint - "+ "got %v, want %v", cap(msg.InvList), wantCap) } - - return } // TestGetDataWire tests the MsgGetData wire encode and decode for various diff --git a/wire/msggetheaders_test.go b/wire/msggetheaders_test.go index f12d422982..545deb3cbf 100644 --- a/wire/msggetheaders_test.go +++ b/wire/msggetheaders_test.go @@ -65,8 +65,6 @@ func TestGetHeaders(t *testing.T) { t.Errorf("AddBlockLocatorHash: expected error on too many " + "block locator hashes not received") } - - return } // TestGetHeadersWire tests the MsgGetHeaders wire encode and decode for various diff --git a/wire/msgheaders_test.go b/wire/msgheaders_test.go index 99e26c9413..1e44c56d23 100644 --- a/wire/msgheaders_test.go +++ b/wire/msgheaders_test.go @@ -55,8 +55,6 @@ func TestHeaders(t *testing.T) { t.Errorf("AddBlockHeader: expected error on too many headers " + "not received") } - - return } // TestHeadersWire tests the MsgHeaders wire encode and decode for various diff --git a/wire/msginv_test.go b/wire/msginv_test.go index e7d8611639..d1f99572d3 100644 --- a/wire/msginv_test.go +++ b/wire/msginv_test.go @@ -66,8 +66,6 @@ func TestInv(t *testing.T) { t.Errorf("NewMsgInvSizeHint: wrong cap for size hint - "+ "got %v, want %v", cap(msg.InvList), wantCap) } - - return } // TestInvWire tests the MsgInv wire encode and decode for various numbers diff --git a/wire/msgmempool_test.go b/wire/msgmempool_test.go index 351287402e..5d05e72128 100644 --- a/wire/msgmempool_test.go +++ b/wire/msgmempool_test.go @@ -59,6 +59,4 @@ func TestMemPool(t *testing.T) { s := "decode of MsgMemPool passed for old protocol version %v err <%v>" t.Errorf(s, msg, err) } - - return } diff --git a/wire/msgnotfound_test.go b/wire/msgnotfound_test.go index 736ac9b24e..2a0886c8d8 100644 --- a/wire/msgnotfound_test.go +++ b/wire/msgnotfound_test.go @@ -57,8 +57,6 @@ func TestNotFound(t *testing.T) { t.Errorf("AddInvVect: expected error on too many inventory " + "vectors not received") } - - return } // TestNotFoundWire tests the MsgNotFound wire encode and decode for various diff --git a/wire/msgping_test.go b/wire/msgping_test.go index 491e49f4f8..7a00dafc73 100644 --- a/wire/msgping_test.go +++ b/wire/msgping_test.go @@ -43,8 +43,6 @@ func TestPing(t *testing.T) { "protocol version %d - got %v, want %v", pver, maxPayload, wantPayload) } - - return } // TestPingBIP0031 tests the MsgPing API against the protocol version @@ -91,8 +89,6 @@ func TestPingBIP0031(t *testing.T) { if msg.Nonce == readmsg.Nonce { t.Errorf("Should not get same nonce for protocol version %d", pver) } - - return } // TestPingCrossProtocol tests the MsgPing API when encoding with the latest diff --git a/wire/msgpong_test.go b/wire/msgpong_test.go index 5e66894834..a6684c08d8 100644 --- a/wire/msgpong_test.go +++ b/wire/msgpong_test.go @@ -61,8 +61,6 @@ func TestPongLatest(t *testing.T) { if msg.Nonce != readmsg.Nonce { t.Errorf("Should get same nonce for protocol version %d", pver) } - - return } // TestPongBIP0031 tests the MsgPong API against the protocol version @@ -108,8 +106,6 @@ func TestPongBIP0031(t *testing.T) { if msg.Nonce == readmsg.Nonce { t.Errorf("Should not get same nonce for protocol version %d", pver) } - - return } // TestPongCrossProtocol tests the MsgPong API when encoding with the latest diff --git a/wire/msgsendheaders_test.go b/wire/msgsendheaders_test.go index 4ef0be0d62..ed6505098e 100644 --- a/wire/msgsendheaders_test.go +++ b/wire/msgsendheaders_test.go @@ -68,8 +68,6 @@ func TestSendHeaders(t *testing.T) { "version %v err <%v>" t.Errorf(s, msg, err) } - - return } // TestSendHeadersBIP0130 tests the MsgSendHeaders API against the protocol @@ -95,8 +93,6 @@ func TestSendHeadersBIP0130(t *testing.T) { t.Errorf("decode of MsgSendHeaders succeeded when it should " + "have failed") } - - return } // TestSendHeadersCrossProtocol tests the MsgSendHeaders API when encoding with diff --git a/wire/msgtx_test.go b/wire/msgtx_test.go index 7a2741e04a..b771fe40f9 100644 --- a/wire/msgtx_test.go +++ b/wire/msgtx_test.go @@ -124,8 +124,6 @@ func TestTx(t *testing.T) { t.Errorf("Copy: mismatched tx messages - got %v, want %v", spew.Sdump(newMsg), spew.Sdump(msg)) } - - return } // TestTxHash tests the ability to generate the hash of a transaction accurately. diff --git a/wire/msgverack_test.go b/wire/msgverack_test.go index a5a4edcfcd..05066f5b46 100644 --- a/wire/msgverack_test.go +++ b/wire/msgverack_test.go @@ -32,8 +32,6 @@ func TestVerAck(t *testing.T) { "protocol version %d - got %v, want %v", pver, maxPayload, wantPayload) } - - return } // TestVerAckWire tests the MsgVerAck wire encode and decode for various diff --git a/wire/msgversion_test.go b/wire/msgversion_test.go index 92f41f056a..9d90a7e8f5 100644 --- a/wire/msgversion_test.go +++ b/wire/msgversion_test.go @@ -124,8 +124,6 @@ func TestVersion(t *testing.T) { if !msg.HasService(SFNodeNetwork) { t.Errorf("HasService: SFNodeNetwork service not set") } - - return } // TestVersionWire tests the MsgVersion wire encode and decode for various