From 53493e34e56f4c64c39d175abaf7afd02f31cd52 Mon Sep 17 00:00:00 2001 From: Samuel Marks Date: Tue, 19 Mar 2019 11:30:01 +1100 Subject: [PATCH] cmd/puppeth/wizard_genesis.go,eth/handler.go,les/benchmark.go,les/handler.go,metrics/exp/exp.go,signer/core/api.go,swarm/api/client/client.go,swarm/network/stream/snapshot_sync_test.go,swarm/network/stream/stream.go,swarm/pss/pss.go,swarm/storage/feed/lookup/lookup.go,swarm/storage/hasherstore.go,whisper/whisperv6/envelope.go,whisper/whisperv6/message.go,whisper/whisperv6/peer_test.go: Removed redundant parentheses --- cmd/puppeth/wizard_genesis.go | 2 +- eth/handler.go | 2 +- les/benchmark.go | 2 +- les/handler.go | 2 +- metrics/exp/exp.go | 2 +- signer/core/api.go | 2 +- swarm/api/client/client.go | 2 +- swarm/network/stream/snapshot_sync_test.go | 2 +- swarm/network/stream/stream.go | 4 ++-- swarm/pss/pss.go | 2 +- swarm/storage/feed/lookup/lookup.go | 4 ++-- swarm/storage/hasherstore.go | 2 +- whisper/whisperv6/envelope.go | 2 +- whisper/whisperv6/message.go | 2 +- whisper/whisperv6/peer_test.go | 4 ++-- 15 files changed, 18 insertions(+), 18 deletions(-) diff --git a/cmd/puppeth/wizard_genesis.go b/cmd/puppeth/wizard_genesis.go index 6aed09f141..dbe7a279f8 100644 --- a/cmd/puppeth/wizard_genesis.go +++ b/cmd/puppeth/wizard_genesis.go @@ -249,7 +249,7 @@ func (w *wizard) manageGenesis() { // Export the native genesis spec used by puppeth and Geth gethJson := filepath.Join(folder, fmt.Sprintf("%s.json", w.network)) - if err := ioutil.WriteFile((gethJson), out, 0644); err != nil { + if err := ioutil.WriteFile(gethJson, out, 0644); err != nil { log.Error("Failed to save genesis file", "err", err) return } diff --git a/eth/handler.go b/eth/handler.go index b42612a566..6d96daa3b7 100644 --- a/eth/handler.go +++ b/eth/handler.go @@ -392,7 +392,7 @@ func (pm *ProtocolManager) handleMsg(p *peer) error { unknown = true } else { query.Origin.Hash, query.Origin.Number = pm.blockchain.GetAncestor(query.Origin.Hash, query.Origin.Number, ancestor, &maxNonCanonical) - unknown = (query.Origin.Hash == common.Hash{}) + unknown = query.Origin.Hash == common.Hash{} } case hashMode && !query.Reverse: // Hash based traversal towards the leaf block diff --git a/les/benchmark.go b/les/benchmark.go index cb302c6ea5..f86f61f207 100644 --- a/les/benchmark.go +++ b/les/benchmark.go @@ -135,7 +135,7 @@ func (b *benchmarkHelperTrie) init(pm *ProtocolManager, count int) error { b.sectionCount, b.headNum, _ = pm.server.bloomTrieIndexer.Sections() } else { b.sectionCount, _, _ = pm.server.chtIndexer.Sections() - b.sectionCount /= (params.CHTFrequencyClient / params.CHTFrequencyServer) + b.sectionCount /= params.CHTFrequencyClient / params.CHTFrequencyServer b.headNum = b.sectionCount*params.CHTFrequencyClient - 1 } if b.sectionCount == 0 { diff --git a/les/handler.go b/les/handler.go index 50c32fb958..618be5abc0 100644 --- a/les/handler.go +++ b/les/handler.go @@ -493,7 +493,7 @@ func (pm *ProtocolManager) handleMsg(p *peer) error { unknown = true } else { query.Origin.Hash, query.Origin.Number = pm.blockchain.GetAncestor(query.Origin.Hash, query.Origin.Number, ancestor, &maxNonCanonical) - unknown = (query.Origin.Hash == common.Hash{}) + unknown = query.Origin.Hash == common.Hash{} } case hashMode && !query.Reverse: // Hash based traversal towards the leaf block diff --git a/metrics/exp/exp.go b/metrics/exp/exp.go index 325a193c77..ee6545e2b2 100644 --- a/metrics/exp/exp.go +++ b/metrics/exp/exp.go @@ -111,7 +111,7 @@ func (exp *exp) publishMeter(name string, metric metrics.Meter) { exp.getInt(name + ".count").Set(m.Count()) exp.getFloat(name + ".one-minute").Set(m.Rate1()) exp.getFloat(name + ".five-minute").Set(m.Rate5()) - exp.getFloat(name + ".fifteen-minute").Set((m.Rate15())) + exp.getFloat(name + ".fifteen-minute").Set(m.Rate15()) exp.getFloat(name + ".mean").Set(m.RateMean()) } diff --git a/signer/core/api.go b/signer/core/api.go index 184b903103..3324aba4a1 100644 --- a/signer/core/api.go +++ b/signer/core/api.go @@ -376,7 +376,7 @@ func (api *SignerAPI) New(ctx context.Context) (common.Address, error) { continue } if pwErr := ValidatePasswordFormat(resp.Text); pwErr != nil { - api.UI.ShowError(fmt.Sprintf("Account creation attempt #%d failed due to password requirements: %v", (i + 1), pwErr)) + api.UI.ShowError(fmt.Sprintf("Account creation attempt #%d failed due to password requirements: %v", i + 1, pwErr)) } else { // No error acc, err := be[0].(*keystore.KeyStore).NewAccount(resp.Text) diff --git a/swarm/api/client/client.go b/swarm/api/client/client.go index 5e293cca72..dfedba92bc 100644 --- a/swarm/api/client/client.go +++ b/swarm/api/client/client.go @@ -102,7 +102,7 @@ func (c *Client) DownloadRaw(hash string) (io.ReadCloser, bool, error) { res.Body.Close() return nil, false, fmt.Errorf("unexpected HTTP status: %s", res.Status) } - isEncrypted := (res.Header.Get("X-Decrypted") == "true") + isEncrypted := res.Header.Get("X-Decrypted") == "true" return res.Body, isEncrypted, nil } diff --git a/swarm/network/stream/snapshot_sync_test.go b/swarm/network/stream/snapshot_sync_test.go index 9737ec0a54..38d4bc2802 100644 --- a/swarm/network/stream/snapshot_sync_test.go +++ b/swarm/network/stream/snapshot_sync_test.go @@ -314,7 +314,7 @@ func uploadFileToSingleNodeStore(id enode.ID, chunkCount int, lstore *storage.Lo if err != nil { return nil, err } - rootAddrs = append(rootAddrs, (rk)) + rootAddrs = append(rootAddrs, rk) } return rootAddrs, nil diff --git a/swarm/network/stream/stream.go b/swarm/network/stream/stream.go index c7c489152a..f0f1a4ec93 100644 --- a/swarm/network/stream/stream.go +++ b/swarm/network/stream/stream.go @@ -629,11 +629,11 @@ func (p *Peer) HandleMsg(ctx context.Context, msg interface{}) error { case *ChunkDeliveryMsgRetrieval: // handling chunk delivery is the same for retrieval and syncing, so let's cast the msg - return p.streamer.delivery.handleChunkDeliveryMsg(ctx, p, ((*ChunkDeliveryMsg)(msg))) + return p.streamer.delivery.handleChunkDeliveryMsg(ctx, p, (*ChunkDeliveryMsg)(msg)) case *ChunkDeliveryMsgSyncing: // handling chunk delivery is the same for retrieval and syncing, so let's cast the msg - return p.streamer.delivery.handleChunkDeliveryMsg(ctx, p, ((*ChunkDeliveryMsg)(msg))) + return p.streamer.delivery.handleChunkDeliveryMsg(ctx, p, (*ChunkDeliveryMsg)(msg)) case *RetrieveRequestMsg: return p.streamer.delivery.handleRetrieveRequestMsg(ctx, p, msg) diff --git a/swarm/pss/pss.go b/swarm/pss/pss.go index 0d02c9b8de..fb22128e5e 100644 --- a/swarm/pss/pss.go +++ b/swarm/pss/pss.go @@ -386,7 +386,7 @@ func (p *Pss) handlePssMsg(ctx context.Context, msg interface{}) error { return nil } if p.checkFwdCache(pssmsg) { - log.Trace("pss relay block-cache match (process)", "from", common.ToHex(p.Kademlia.BaseAddr()), "to", (common.ToHex(pssmsg.To))) + log.Trace("pss relay block-cache match (process)", "from", common.ToHex(p.Kademlia.BaseAddr()), "to", common.ToHex(pssmsg.To)) return nil } p.addFwdCache(pssmsg) diff --git a/swarm/storage/feed/lookup/lookup.go b/swarm/storage/feed/lookup/lookup.go index 2f862d81c4..a3b06045f1 100644 --- a/swarm/storage/feed/lookup/lookup.go +++ b/swarm/storage/feed/lookup/lookup.go @@ -75,12 +75,12 @@ func Hint(last uint64) Epoch { func GetNextLevel(last Epoch, now uint64) uint8 { // First XOR the last epoch base time with the current clock. // This will set all the common most significant bits to zero. - mix := (last.Base() ^ now) + mix := last.Base() ^ now // Then, make sure we stop the below loop before one level below the current, by setting // that level's bit to 1. // If the next level is lower than the current one, it must be exactly level-1 and not lower. - mix |= (1 << (last.Level - 1)) + mix |= 1 << (last.Level - 1) // if the last update was more than 2^highestLevel seconds ago, choose the highest level if mix > (maxuint64 >> (64 - HighestLevel - 1)) { diff --git a/swarm/storage/hasherstore.go b/swarm/storage/hasherstore.go index 345ce7430a..97bd0fe5a5 100644 --- a/swarm/storage/hasherstore.go +++ b/swarm/storage/hasherstore.go @@ -99,7 +99,7 @@ func (h *hasherStore) Get(ctx context.Context, ref Reference) (ChunkData, error) } chunkData := ChunkData(chunk.Data()) - toDecrypt := (encryptionKey != nil) + toDecrypt := encryptionKey != nil if toDecrypt { var err error chunkData, err = h.decryptChunkData(chunkData, encryptionKey) diff --git a/whisper/whisperv6/envelope.go b/whisper/whisperv6/envelope.go index c42d1fa8ac..5682054b0a 100644 --- a/whisper/whisperv6/envelope.go +++ b/whisper/whisperv6/envelope.go @@ -265,7 +265,7 @@ func TopicToBloom(topic TopicType) []byte { for j := 0; j < 3; j++ { byteIndex := index[j] / 8 bitIndex := index[j] % 8 - b[byteIndex] = (1 << uint(bitIndex)) + b[byteIndex] = 1 << uint(bitIndex) } return b } diff --git a/whisper/whisperv6/message.go b/whisper/whisperv6/message.go index 2d4e862441..185c105618 100644 --- a/whisper/whisperv6/message.go +++ b/whisper/whisperv6/message.go @@ -160,7 +160,7 @@ func (msg *sentMessage) sign(key *ecdsa.PrivateKey) error { hash := crypto.Keccak256(msg.Raw) signature, err := crypto.Sign(hash, key) if err != nil { - msg.Raw[0] &= (0xFF ^ signatureFlag) // clear the flag + msg.Raw[0] &= 0xFF ^ signatureFlag // clear the flag return err } msg.Raw = append(msg.Raw, signature...) diff --git a/whisper/whisperv6/peer_test.go b/whisper/whisperv6/peer_test.go index c5b044e1a6..e4c30f0ccc 100644 --- a/whisper/whisperv6/peer_test.go +++ b/whisper/whisperv6/peer_test.go @@ -418,7 +418,7 @@ func TestPeerBasic(t *testing.T) { func checkPowExchangeForNodeZero(t *testing.T) { const iterations = 200 for j := 0; j < iterations; j++ { - lastCycle := (j == iterations-1) + lastCycle := j == iterations-1 ok := checkPowExchangeForNodeZeroOnce(t, lastCycle) if ok { break @@ -485,7 +485,7 @@ func checkBloomFilterExchangeOnce(t *testing.T, mustPass bool) bool { func checkBloomFilterExchange(t *testing.T) { const iterations = 200 for j := 0; j < iterations; j++ { - lastCycle := (j == iterations-1) + lastCycle := j == iterations-1 ok := checkBloomFilterExchangeOnce(t, lastCycle) if ok { break