From be2b5b7b2f19306d1d5499c7050710e371e3d3bc Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Tue, 25 Jul 2023 10:43:35 +0000 Subject: [PATCH] refactor: remove unnecessary blank identifier Assigning to the blank identifier is unnecessary. --- .../aether/backend/beapiserver/srvmethods.go | 36 +++--- .../aether/backend/dispatch/addrscan.go | 10 +- .../aether/backend/dispatch/bootstrap.go | 10 +- .../aether/backend/dispatch/dispatch.go | 4 +- .../aether/backend/dispatch/exclusions.go | 2 +- .../aether/backend/dispatch/explore.go | 6 +- aether-core/aether/backend/dispatch/ping.go | 7 +- .../aether/backend/dispatch/purgatory.go | 82 ++++++------ .../aether/backend/dispatch/reverseopen.go | 2 +- aether-core/aether/backend/dispatch/sync.go | 14 +- .../responsegenerator/cachegenerator.go | 4 +- .../backend/responsegenerator/entitycount.go | 2 +- .../responsegenerator/indexgenerate.go | 15 ++- .../responsegenerator/mainentitygenerate.go | 3 +- .../responsegenerator/manifestgenerate.go | 18 +-- .../responsegenerator/postrespgenerator.go | 6 +- .../responsegenerator/responsegenerator.go | 6 +- .../backend/responsegenerator/splitter.go | 20 +-- aether-core/aether/backend/swarmtest/main.go | 2 +- .../simplemetricsserver.go | 2 +- .../aether/frontend/beapiconsumer/caching.go | 24 ++-- .../frontend/beapiconsumer/validation.go | 12 +- .../frontend/clapiconsumer/clapiconsumer.go | 18 +-- .../aether/frontend/feapiserver/srvmethods.go | 36 +++--- .../aether/frontend/festructs/ambients.go | 8 +- .../aether/frontend/festructs/batchactions.go | 4 +- .../aether/frontend/festructs/carriers.go | 66 +++++----- .../aether/frontend/festructs/festructs.go | 120 +++++++++--------- .../frontend/festructs/notifications.go | 26 ++-- .../aether/frontend/festructs/protoconv.go | 16 +-- .../frontend/festructs/tssignalcompiler.go | 22 ++-- .../frontend/festructs/tssignalreader.go | 8 +- .../frontend/festructs/vsignalcompiler.go | 17 +-- .../frontend/festructs/vsignalreader.go | 6 +- .../aether/frontend/inflights/inflights.go | 38 +++--- .../aether/frontend/inflights/ingestor.go | 12 +- aether-core/aether/frontend/kvstore/find.go | 14 +- .../aether/frontend/refresher/refresher.go | 20 +-- .../aether/frontend/refresher/views.go | 14 +- aether-core/aether/frontend/search/search.go | 7 +- aether-core/aether/io/api/apistructs.go | 40 +++--- aether-core/aether/io/api/boundscheck.go | 32 ++--- aether-core/aether/io/api/fetcher.go | 14 +- aether-core/aether/io/api/protoconv.go | 8 +- aether-core/aether/io/persistence/reader.go | 30 ++--- aether-core/aether/io/persistence/writer.go | 4 +- aether-core/aether/services/ca/ca.go | 10 +- .../aether/services/configstore/bouncer.go | 40 +++--- .../configstore/fecontentrelations.go | 6 +- .../services/configstore/feuserrelations.go | 2 +- .../services/configstore/responsetracker.go | 6 +- aether-core/aether/services/nonces/nonces.go | 6 +- .../services/rollingbloom/rollingbloom.go | 8 +- .../aether/services/toolbox/toolbox.go | 2 +- 54 files changed, 478 insertions(+), 469 deletions(-) diff --git a/aether-core/aether/backend/beapiserver/srvmethods.go b/aether-core/aether/backend/beapiserver/srvmethods.go index b80d006..6d06b18 100644 --- a/aether-core/aether/backend/beapiserver/srvmethods.go +++ b/aether-core/aether/backend/beapiserver/srvmethods.go @@ -46,7 +46,7 @@ func (s *server) GetBoards( } var apiFps []api.Fingerprint - for key, _ := range fps.Fingerprints { + for key := range fps.Fingerprints { apiFps = append(apiFps, api.Fingerprint(fps.Fingerprints[key])) } apiStart := api.Timestamp(start) @@ -58,7 +58,7 @@ func (s *server) GetBoards( Board_Name: req.GetFilters().GetGraphFilters().GetName(), } result, _ := persistence.Read("boards", apiFps, []string{}, apiStart, apiEnd, true, &opts) - for key, _ := range result.Boards { + for key := range result.Boards { r := result.Boards[key].Protobuf() resp.Boards = append(resp.Boards, &r) } @@ -79,7 +79,7 @@ func (s *server) GetThreads( fps := req.GetFilters().GetFingerprints().GetFingerprints() var apiFps []api.Fingerprint - for key, _ := range fps { + for key := range fps { apiFps = append(apiFps, api.Fingerprint(fps[key])) } apiStart := api.Timestamp(start) @@ -92,7 +92,7 @@ func (s *server) GetThreads( AllProvables_Offset: int(req.GetFilters().GetGraphFilters().GetOffset()), } result, _ := persistence.Read("threads", apiFps, []string{}, apiStart, apiEnd, true, &opts) - for key, _ := range result.Threads { + for key := range result.Threads { r := result.Threads[key].Protobuf() resp.Threads = append(resp.Threads, &r) } @@ -113,7 +113,7 @@ func (s *server) GetPosts( fps := req.GetFilters().GetFingerprints().GetFingerprints() var apiFps []api.Fingerprint - for key, _ := range fps { + for key := range fps { apiFps = append(apiFps, api.Fingerprint(fps[key])) } result, _ := persistence.Read("posts", apiFps, []string{}, start, end, true, &persistence.OptionalReadInputs{ @@ -124,7 +124,7 @@ func (s *server) GetPosts( AllProvables_Limit: int(req.GetFilters().GetGraphFilters().GetLimit()), AllProvables_Offset: int(req.GetFilters().GetGraphFilters().GetOffset()), }) - for key, _ := range result.Posts { + for key := range result.Posts { r := result.Posts[key].Protobuf() resp.Posts = append(resp.Posts, &r) } @@ -145,7 +145,7 @@ func (s *server) GetVotes( fps := req.GetFilters().GetFingerprints().GetFingerprints() var apiFps []api.Fingerprint - for key, _ := range fps { + for key := range fps { apiFps = append(apiFps, api.Fingerprint(fps[key])) } result, _ := persistence.Read("votes", apiFps, []string{}, start, end, true, @@ -160,7 +160,7 @@ func (s *server) GetVotes( AllProvables_Limit: int(req.GetFilters().GetGraphFilters().GetLimit()), AllProvables_Offset: int(req.GetFilters().GetGraphFilters().GetOffset()), }) - for key, _ := range result.Votes { + for key := range result.Votes { r := result.Votes[key].Protobuf() resp.Votes = append(resp.Votes, &r) } @@ -184,7 +184,7 @@ func (s *server) GetKeys( } var apiFps []api.Fingerprint - for key, _ := range fps.Fingerprints { + for key := range fps.Fingerprints { apiFps = append(apiFps, api.Fingerprint(fps.Fingerprints[key])) } apiStart := api.Timestamp(start) @@ -196,7 +196,7 @@ func (s *server) GetKeys( Key_Name: req.GetFilters().GetGraphFilters().GetName(), } result, _ := persistence.Read("keys", apiFps, []string{}, apiStart, apiEnd, true, &opts) - for key, _ := range result.Keys { + for key := range result.Keys { r := result.Keys[key].Protobuf() resp.Keys = append(resp.Keys, &r) } @@ -217,7 +217,7 @@ func (s *server) GetTruststates( fps := req.GetFilters().GetFingerprints().GetFingerprints() var apiFps []api.Fingerprint - for key, _ := range fps { + for key := range fps { apiFps = append(apiFps, api.Fingerprint(fps[key])) } result, _ := persistence.Read("truststates", apiFps, []string{}, start, end, true, @@ -230,7 +230,7 @@ func (s *server) GetTruststates( AllProvables_Limit: int(req.GetFilters().GetGraphFilters().GetLimit()), AllProvables_Offset: int(req.GetFilters().GetGraphFilters().GetOffset()), }) - for key, _ := range result.Truststates { + for key := range result.Truststates { r := result.Truststates[key].Protobuf() resp.Truststates = append(resp.Truststates, &r) } @@ -301,7 +301,7 @@ func (s *server) SendMintedContent( var allItems []interface{} boardsProto := req.GetBoards() - for k, _ := range boardsProto { + for k := range boardsProto { e := api.Board{} e.FillFromProtobuf(*boardsProto[k]) err2 := api.Verify(api.Provable(&e)) @@ -313,7 +313,7 @@ func (s *server) SendMintedContent( allItems = append(allItems, interface{}(e)) } threadsProto := req.GetThreads() - for k, _ := range threadsProto { + for k := range threadsProto { e := api.Thread{} e.FillFromProtobuf(*threadsProto[k]) err2 := api.Verify(api.Provable(&e)) @@ -325,7 +325,7 @@ func (s *server) SendMintedContent( allItems = append(allItems, interface{}(e)) } postsProto := req.GetPosts() - for k, _ := range postsProto { + for k := range postsProto { e := api.Post{} e.FillFromProtobuf(*postsProto[k]) err2 := api.Verify(api.Provable(&e)) @@ -337,7 +337,7 @@ func (s *server) SendMintedContent( allItems = append(allItems, interface{}(e)) } votesProto := req.GetVotes() - for k, _ := range votesProto { + for k := range votesProto { e := api.Vote{} e.FillFromProtobuf(*votesProto[k]) err2 := api.Verify(api.Provable(&e)) @@ -349,7 +349,7 @@ func (s *server) SendMintedContent( allItems = append(allItems, interface{}(e)) } keysProto := req.GetKeys() - for k, _ := range keysProto { + for k := range keysProto { e := api.Key{} e.FillFromProtobuf(*keysProto[k]) err2 := api.Verify(api.Provable(&e)) @@ -361,7 +361,7 @@ func (s *server) SendMintedContent( allItems = append(allItems, interface{}(e)) } truststatesProto := req.GetTruststates() - for k, _ := range truststatesProto { + for k := range truststatesProto { e := api.Truststate{} e.FillFromProtobuf(*truststatesProto[k]) err2 := api.Verify(api.Provable(&e)) diff --git a/aether-core/aether/backend/dispatch/addrscan.go b/aether-core/aether/backend/dispatch/addrscan.go index 8855776..580f7b3 100644 --- a/aether-core/aether/backend/dispatch/addrscan.go +++ b/aether-core/aether/backend/dispatch/addrscan.go @@ -41,7 +41,7 @@ func filterByLastSuccessfulPing(addrs []api.Address, scanStart api.Timestamp) [] cutoff := api.Timestamp(time.Unix(int64(scanStart), 0).Add(-2 * time.Minute).Unix()) // Cutoff is 2 minutes before the threshold, because our pinger accepts a node whose last successful ping was within 2 minutes as online. - for key, _ := range addrs { + for key := range addrs { if addrs[key].LastSuccessfulPing >= cutoff { live = append(live, addrs[key]) } @@ -54,7 +54,7 @@ func filterByAddressType(addrType uint8, addrs []api.Address) ([]api.Address, [] var remainder []api.Address - for key, _ := range addrs { + for key := range addrs { if addrs[key].Type == addrType { filteredAddrs = append(filteredAddrs, addrs[key]) } else { @@ -246,14 +246,14 @@ func findOnlineNodesV2(count int, reqType, addrType int, excl *[]api.Address, re if !reverse { // If this is a non-reverse (normal) find online request, we use the reverse dispatcher exclusion queue. - for k, _ := range liveNodes { + for k := range liveNodes { if !dpe.IsExcluded(liveNodes[k]) { l = append(l, liveNodes[k]) } } } else { // If this is a reverse find online request, we use the reverse dispatcher exclusion queue. - for k, _ := range liveNodes { + for k := range liveNodes { if !reverseDpe.IsExcluded(liveNodes[k]) { l = append(l, liveNodes[k]) } @@ -273,7 +273,7 @@ func pickUnconnectedAddrs(addrs []api.Address) ([]api.Address, []api.Address) { var connecteds []api.Address - for key, _ := range addrs { + for key := range addrs { if addrs[key].LastSuccessfulSync == 0 { nonconnecteds = append(nonconnecteds, addrs[key]) } else { diff --git a/aether-core/aether/backend/dispatch/bootstrap.go b/aether-core/aether/backend/dispatch/bootstrap.go index 6a78588..c9e8ed9 100644 --- a/aether-core/aether/backend/dispatch/bootstrap.go +++ b/aether-core/aether/backend/dispatch/bootstrap.go @@ -56,7 +56,7 @@ func constructExecPlans(bootstrappers []api.Address) []execPlan { } var execplans []execPlan - for key, _ := range bootstrappers { + for key := range bootstrappers { execplans = append(execplans, execPlan{addr: bootstrappers[key]}) } servingSubprots := globals.BackendConfig.GetServingSubprotocols() @@ -65,7 +65,7 @@ func constructExecPlans(bootstrappers []api.Address) []execPlan { for _, subprot := range servingSubprots { entities = append(entities, subprot.SupportedEntities...) } - for key, _ := range entities { + for key := range entities { mod := key % len(execplans) // 0 % 7 = 0, 3 % 7 = 3, 7 % 7 = 0 (loops over) execplans[mod].endpoints = append(execplans[mod].endpoints, entities[key]) } @@ -100,7 +100,7 @@ func doBootstrap() { feapiconsumer.BackendAmbientStatus.LastBootstrapTimestamp = lastBs feapiconsumer.BackendAmbientStatus.TriggerBootstrapRefresh = true logging.Logf(1, "Bootstrap successful. Here are the bootstrappers that are about to be added to the exclusions list. %#v", onlineBootstrappers) - for k, _ := range onlineBootstrappers { + for k := range onlineBootstrappers { dpe.Add(onlineBootstrappers[k]) // ^ If the bootstrap was successful, we mark all of them as hit. @@ -120,7 +120,7 @@ func doBootstrap() { var errs []error // Go through each remote in the exec plans and call them based on the types we want to pull from it. - for key, _ := range execPlans { + for key := range execPlans { err := Sync(execPlans[key].addr, execPlans[key].endpoints, nil) if err != nil { errs = append(errs, err) @@ -128,7 +128,7 @@ func doBootstrap() { } // If there are more than one bootstrap remote, go through each remote in the exec plan and call all endpoints in them. This should cause a manifest scan and not much download, and a timestamp setting. This is insurance to make sure that the data we have is the union of all bootstrappers we connected to. if len(execPlans) > 1 { - for key, _ := range execPlans { + for key := range execPlans { err := Sync(execPlans[key].addr, []string{}, nil) if err != nil { errs = append(errs, err) diff --git a/aether-core/aether/backend/dispatch/dispatch.go b/aether-core/aether/backend/dispatch/dispatch.go index 0490081..7eef688 100644 --- a/aether-core/aether/backend/dispatch/dispatch.go +++ b/aether-core/aether/backend/dispatch/dispatch.go @@ -113,7 +113,7 @@ func Scout() error { return errors.New("Scout got no unconnected addresses. Bailing.") } attempts := 0 - for k, _ := range addrs { + for k := range addrs { attempts++ if attempts > scoutAttempts { break @@ -261,7 +261,7 @@ func sameAddress(a1 *api.Address, a2 *api.Address) bool { func addrsInGivenSlice(addr *api.Address, slc *[]api.Address) bool { address := *addr slice := *slc - for i, _ := range slice { + for i := range slice { if sameAddress(&address, &slice[i]) { return true } diff --git a/aether-core/aether/backend/dispatch/exclusions.go b/aether-core/aether/backend/dispatch/exclusions.go index 1026e79..0e3a8a7 100644 --- a/aether-core/aether/backend/dispatch/exclusions.go +++ b/aether-core/aether/backend/dispatch/exclusions.go @@ -67,7 +67,7 @@ func (d *dispatcherExclusions) maintain() { maintenanceCutoff := now.Add(-1 * time.Hour).Unix() exclusionsCutoff := now.Add(-12 * time.Hour).Unix() if d.LastMaintained > maintenanceCutoff { - for k, _ := range d.Exclusions { + for k := range d.Exclusions { if d.Exclusions[k].Unix() > exclusionsCutoff { delete(d.Exclusions, k) } diff --git a/aether-core/aether/backend/dispatch/explore.go b/aether-core/aether/backend/dispatch/explore.go index 292c493..e438592 100644 --- a/aether-core/aether/backend/dispatch/explore.go +++ b/aether-core/aether/backend/dispatch/explore.go @@ -34,7 +34,7 @@ func Explore() { logging.Logf(1, "There was an error when we tried to read static bootstrapper addresses for Explore schedule. Error: %#v", err2) } bsAddrs := append(liveBs, staticBs...) - for key, _ := range bsAddrs { + for key := range bsAddrs { Sync(bsAddrs[key], []string{}, nil) } // call all CA nodes and sync with them. These should be fairly short. We are not limiting them to x number of CAs because each CA will likely have their own data only. (We terminate the connection without sync if it's a CA that we do not trust.) @@ -47,7 +47,7 @@ func Explore() { logging.Logf(1, "There was an error when we tried to read static CA addresses for Explore schedule. Error: %#v", err4) } caAddrs := append(liveCA, staticCA...) - for key, _ := range caAddrs { + for key := range caAddrs { Sync(caAddrs[key], []string{}, nil) } } else if ticker%6 == 0 && ticker != 0 { @@ -62,7 +62,7 @@ func Explore() { if err != nil { logging.Logf(1, "There was an error when we tried to read static addresses for Explore schedule. Error: %#v", err) } - for key, _ := range statics { + for key := range statics { Sync(statics[key], []string{}, nil) } } else { diff --git a/aether-core/aether/backend/dispatch/ping.go b/aether-core/aether/backend/dispatch/ping.go index 19d7bba..150daa8 100644 --- a/aether-core/aether/backend/dispatch/ping.go +++ b/aether-core/aether/backend/dispatch/ping.go @@ -8,6 +8,7 @@ import ( // "aether-core/aether/io/persistence" "aether-core/aether/services/globals" "aether-core/aether/services/logging" + // "aether-core/aether/services/safesleep" // "errors" "fmt" @@ -43,7 +44,7 @@ func Pinger(fullAddressesSlice []api.Address) []api.Address { pages = append(pages, page) } // For every page, - for i, _ := range pages { + for i := range pages { // If there's a shutdown in progress, break and exit. if globals.BackendTransientConfig.ShutdownInitiated { return []api.Address{} @@ -52,7 +53,7 @@ func Pinger(fullAddressesSlice []api.Address) []api.Address { // Run the core logic. addrs := pages[i] outputChan := make(chan api.Address) - for j, _ := range addrs { + for j := range addrs { // Check if shutdown was initiated. if globals.BackendTransientConfig.ShutdownInitiated { break // Stop processing and return @@ -72,7 +73,7 @@ func Pinger(fullAddressesSlice []api.Address) []api.Address { // Clean blanks. logging.Log(2, fmt.Sprintf("All updated addresses count (this should be the same as goroutine count: %d", len(allUpdatedAddresses))) var cleanedAllUpdatedAddresses []api.Address - for i, _ := range allUpdatedAddresses { + for i := range allUpdatedAddresses { if allUpdatedAddresses[i].Location != "" { // The location is not blank. This is an actual updated address. cleanedAllUpdatedAddresses = append(cleanedAllUpdatedAddresses, allUpdatedAddresses[i]) diff --git a/aether-core/aether/backend/dispatch/purgatory.go b/aether-core/aether/backend/dispatch/purgatory.go index dbec4b1..7b19006 100644 --- a/aether-core/aether/backend/dispatch/purgatory.go +++ b/aether-core/aether/backend/dispatch/purgatory.go @@ -56,37 +56,37 @@ type Purgatory struct { func (p *Purgatory) indexOf(item api.Provable) int { switch entity := item.(type) { case *api.Board: - for key, _ := range p.BoardsPurg { + for key := range p.BoardsPurg { if p.BoardsPurg[key].Fingerprint == entity.Fingerprint { return key } } case *api.Thread: - for key, _ := range p.ThreadsPurg { + for key := range p.ThreadsPurg { if p.ThreadsPurg[key].Fingerprint == entity.Fingerprint { return key } } case *api.Post: - for key, _ := range p.PostsPurg { + for key := range p.PostsPurg { if p.PostsPurg[key].Fingerprint == entity.Fingerprint { return key } } case *api.Vote: - for key, _ := range p.VotesPurg { + for key := range p.VotesPurg { if p.VotesPurg[key].Fingerprint == entity.Fingerprint { return key } } case *api.Key: - for key, _ := range p.KeysPurg { + for key := range p.KeysPurg { if p.KeysPurg[key].Fingerprint == entity.Fingerprint { return key } } case *api.Truststate: - for key, _ := range p.TruststatesPurg { + for key := range p.TruststatesPurg { if p.TruststatesPurg[key].Fingerprint == entity.Fingerprint { return key } @@ -166,22 +166,22 @@ func cnvToVertexIdx(item api.ProvableIndex) vertex { func (p *Purgatory) getDirectDescendants(vs []vertex) []vertex { var children []vertex - for key1, _ := range vs { + for key1 := range vs { switch vs[key1].entityType { case "board": - for key, _ := range p.ThreadIndexes { + for key := range p.ThreadIndexes { if p.ThreadIndexes[key].Board == vs[key1].fingerprint { children = append(children, cnvToVertexIdx(&p.ThreadIndexes[key])) } } case "thread": - for key, _ := range p.PostIndexes { + for key := range p.PostIndexes { if p.PostIndexes[key].Thread == vs[key1].fingerprint { children = append(children, cnvToVertexIdx(&p.PostIndexes[key])) } } case "post": - for key, _ := range p.PostIndexes { + for key := range p.PostIndexes { if p.PostIndexes[key].Parent == vs[key1].fingerprint { children = append(children, cnvToVertexIdx(&p.PostIndexes[key])) } @@ -189,27 +189,27 @@ func (p *Purgatory) getDirectDescendants(vs []vertex) []vertex { case "vote": // no descendants case "key": - for key, _ := range p.BoardIndexes { + for key := range p.BoardIndexes { if p.BoardIndexes[key].Owner == vs[key1].fingerprint { children = append(children, cnvToVertexIdx(&p.BoardIndexes[key])) } } - for key, _ := range p.ThreadIndexes { + for key := range p.ThreadIndexes { if p.ThreadIndexes[key].Owner == vs[key1].fingerprint { children = append(children, cnvToVertexIdx(&p.ThreadIndexes[key])) } } - for key, _ := range p.PostIndexes { + for key := range p.PostIndexes { if p.PostIndexes[key].Owner == vs[key1].fingerprint { children = append(children, cnvToVertexIdx(&p.PostIndexes[key])) } } - for key, _ := range p.VoteIndexes { + for key := range p.VoteIndexes { if p.VoteIndexes[key].Owner == vs[key1].fingerprint { children = append(children, cnvToVertexIdx(&p.VoteIndexes[key])) } } - for key, _ := range p.TruststateIndexes { + for key := range p.TruststateIndexes { if p.TruststateIndexes[key].Owner == vs[key1].fingerprint { children = append(children, cnvToVertexIdx(&p.TruststateIndexes[key])) } @@ -225,7 +225,7 @@ func (p *Purgatory) getDirectDescendants(vs []vertex) []vertex { func getMostRecentLastModified(vs []vertex) api.Timestamp { var mostRecentLm api.Timestamp - for key, _ := range vs { + for key := range vs { if vs[key].lastModified > mostRecentLm { mostRecentLm = vs[key].lastModified } @@ -309,32 +309,32 @@ func (p *Purgatory) process() { var newTs []api.Truststate - for key, _ := range p.BoardsPurg { + for key := range p.BoardsPurg { if p.verify(&p.BoardsPurg[key]) { newB = append(newB, p.BoardsPurg[key]) } } - for key, _ := range p.ThreadsPurg { + for key := range p.ThreadsPurg { if p.verify(&p.ThreadsPurg[key]) { newT = append(newT, p.ThreadsPurg[key]) } } - for key, _ := range p.PostsPurg { + for key := range p.PostsPurg { if p.verify(&p.PostsPurg[key]) { newP = append(newP, p.PostsPurg[key]) } } - for key, _ := range p.VotesPurg { + for key := range p.VotesPurg { if p.verify(&p.VotesPurg[key]) { newV = append(newV, p.VotesPurg[key]) } } - for key, _ := range p.KeysPurg { + for key := range p.KeysPurg { if p.verify(&p.KeysPurg[key]) { newK = append(newK, p.KeysPurg[key]) } } - for key, _ := range p.TruststatesPurg { + for key := range p.TruststatesPurg { if p.verify(&p.TruststatesPurg[key]) { newTs = append(newTs, p.TruststatesPurg[key]) } @@ -349,22 +349,22 @@ func (p *Purgatory) process() { func (p *Purgatory) convertAllToIface() []interface{} { var carrier []interface{} - for i, _ := range p.BoardsPurg { + for i := range p.BoardsPurg { carrier = append(carrier, p.BoardsPurg[i]) } - for i, _ := range p.ThreadsPurg { + for i := range p.ThreadsPurg { carrier = append(carrier, p.ThreadsPurg[i]) } - for i, _ := range p.PostsPurg { + for i := range p.PostsPurg { carrier = append(carrier, p.PostsPurg[i]) } - for i, _ := range p.VotesPurg { + for i := range p.VotesPurg { carrier = append(carrier, p.VotesPurg[i]) } - for i, _ := range p.KeysPurg { + for i := range p.KeysPurg { carrier = append(carrier, p.KeysPurg[i]) } - for i, _ := range p.TruststatesPurg { + for i := range p.TruststatesPurg { carrier = append(carrier, p.TruststatesPurg[i]) } return carrier @@ -402,7 +402,7 @@ func (p *Purgatory) accept(items []api.Provable) { // nhD := globals.BackendConfig.GetNetworkHeadDays() // nhCutoff := api.Timestamp(toolbox.CnvToCutoffDays(nhD)) cutoff := api.Timestamp(globals.BackendConfig.GetEventHorizonTimestamp()) // todo: should purgatory be gated on network head or event horizon? - for key, _ := range items { + for key := range items { // gate := calcGate(items[key]) if cutoff > items[key].GetLastModified() { // Entity older than our network head. Enters purgatory. @@ -487,7 +487,7 @@ func (p *Purgatory) removeFromResp(r *api.Response) { if len(r.Boards) > 0 { var removalIdxs []int - for key, _ := range p.BoardsPurg { + for key := range p.BoardsPurg { idx := r.IndexOf(&p.BoardsPurg[key]) if idx != -1 { removalIdxs = append(removalIdxs, idx) @@ -498,7 +498,7 @@ func (p *Purgatory) removeFromResp(r *api.Response) { if len(r.Threads) > 0 { var removalIdxs []int - for key, _ := range p.ThreadsPurg { + for key := range p.ThreadsPurg { idx := r.IndexOf(&p.ThreadsPurg[key]) if idx != -1 { removalIdxs = append(removalIdxs, idx) @@ -509,7 +509,7 @@ func (p *Purgatory) removeFromResp(r *api.Response) { if len(r.Posts) > 0 { var removalIdxs []int - for key, _ := range p.PostsPurg { + for key := range p.PostsPurg { idx := r.IndexOf(&p.PostsPurg[key]) if idx != -1 { removalIdxs = append(removalIdxs, idx) @@ -520,7 +520,7 @@ func (p *Purgatory) removeFromResp(r *api.Response) { if len(r.Votes) > 0 { var removalIdxs []int - for key, _ := range p.VotesPurg { + for key := range p.VotesPurg { idx := r.IndexOf(&p.VotesPurg[key]) if idx != -1 { removalIdxs = append(removalIdxs, idx) @@ -531,7 +531,7 @@ func (p *Purgatory) removeFromResp(r *api.Response) { if len(r.Keys) > 0 { var removalIdxs []int - for key, _ := range p.KeysPurg { + for key := range p.KeysPurg { idx := r.IndexOf(&p.KeysPurg[key]) if idx != -1 { removalIdxs = append(removalIdxs, idx) @@ -542,7 +542,7 @@ func (p *Purgatory) removeFromResp(r *api.Response) { if len(r.Truststates) > 0 { var removalIdxs []int - for key, _ := range p.TruststatesPurg { + for key := range p.TruststatesPurg { idx := r.IndexOf(&p.TruststatesPurg[key]) if idx != -1 { removalIdxs = append(removalIdxs, idx) @@ -558,32 +558,32 @@ func (p *Purgatory) Filter(r *api.Response) { start := time.Now() var bProv []api.Provable - for key, _ := range r.Boards { + for key := range r.Boards { bProv = append(bProv, api.Provable(&r.Boards[key])) } var tProv []api.Provable - for key, _ := range r.Threads { + for key := range r.Threads { tProv = append(tProv, api.Provable(&r.Threads[key])) } var pProv []api.Provable - for key, _ := range r.Posts { + for key := range r.Posts { pProv = append(pProv, api.Provable(&r.Posts[key])) } var vProv []api.Provable - for key, _ := range r.Votes { + for key := range r.Votes { vProv = append(vProv, api.Provable(&r.Votes[key])) } var kProv []api.Provable - for key, _ := range r.Keys { + for key := range r.Keys { kProv = append(kProv, api.Provable(&r.Keys[key])) } var tsProv []api.Provable - for key, _ := range r.Truststates { + for key := range r.Truststates { tsProv = append(tsProv, api.Provable(&r.Truststates[key])) } p.accept(bProv) diff --git a/aether-core/aether/backend/dispatch/reverseopen.go b/aether-core/aether/backend/dispatch/reverseopen.go index 65a8804..2f60c22 100644 --- a/aether-core/aether/backend/dispatch/reverseopen.go +++ b/aether-core/aether/backend/dispatch/reverseopen.go @@ -107,7 +107,7 @@ func ReverseScout() error { return errors.New("ReverseScout got no unconnected addresses. Bailing.") } attempts := 0 - for k, _ := range addrs { + for k := range addrs { if addrs[k].LocationType == 3 { continue // If it's an URL (type=3), we don't attempt to do a reverse open. diff --git a/aether-core/aether/backend/dispatch/sync.go b/aether-core/aether/backend/dispatch/sync.go index af76484..b367724 100644 --- a/aether-core/aether/backend/dispatch/sync.go +++ b/aether-core/aether/backend/dispatch/sync.go @@ -522,25 +522,25 @@ func constructCallOrder(remote api.Address, lineup []string) []string { func prepareForBatchInsert(r *api.Response) *[]interface{} { resp := *r var carrier []interface{} - for i, _ := range resp.Boards { + for i := range resp.Boards { carrier = append(carrier, resp.Boards[i]) } - for i, _ := range resp.Threads { + for i := range resp.Threads { carrier = append(carrier, resp.Threads[i]) } - for i, _ := range resp.Posts { + for i := range resp.Posts { carrier = append(carrier, resp.Posts[i]) } - for i, _ := range resp.Votes { + for i := range resp.Votes { carrier = append(carrier, resp.Votes[i]) } - for i, _ := range resp.Keys { + for i := range resp.Keys { carrier = append(carrier, resp.Keys[i]) } - for i, _ := range resp.Truststates { + for i := range resp.Truststates { carrier = append(carrier, resp.Truststates[i]) } - for i, _ := range resp.Addresses { + for i := range resp.Addresses { carrier = append(carrier, resp.Addresses[i]) } return &carrier diff --git a/aether-core/aether/backend/responsegenerator/cachegenerator.go b/aether-core/aether/backend/responsegenerator/cachegenerator.go index 1e3b80c..1e8d628 100644 --- a/aether-core/aether/backend/responsegenerator/cachegenerator.go +++ b/aether-core/aether/backend/responsegenerator/cachegenerator.go @@ -198,7 +198,7 @@ func deleteTooOldCaches(etype string, cacheIndex *api.ApiResponse) { } // Now, we want to take a look at the folder structure, and see which ones need to go. validsMap := make(map[string]bool) - for k, _ := range cacheIndex.Results { + for k := range cacheIndex.Results { validsMap[cacheIndex.Results[k].ResponseUrl] = true } folders, err := ioutil.ReadDir(entityCacheDir) @@ -206,7 +206,7 @@ func deleteTooOldCaches(etype string, cacheIndex *api.ApiResponse) { logging.Logf(1, "deleteTooOldCaches had an error trying to read the cache directory. Dir: %v, Error: %v", entityCacheDir, err) return } - for k, _ := range folders { + for k := range folders { cacheName := folders[k].Name() if cacheName == "index.json" { // This folder not only has cache folders. Avoid that one. diff --git a/aether-core/aether/backend/responsegenerator/entitycount.go b/aether-core/aether/backend/responsegenerator/entitycount.go index 43c0eee..38bc213 100644 --- a/aether-core/aether/backend/responsegenerator/entitycount.go +++ b/aether-core/aether/backend/responsegenerator/entitycount.go @@ -94,7 +94,7 @@ func mergeCounts(entityCount *[]api.EntityCount, csEntityCount configstore.Entit return ec } // ec := *entityCount // create a copy, don't manipulate the original - for i, _ := range ec { + for i := range ec { if ec[i].Name == csEntityCount.Name { ec[i].Count = ec[i].Count + csEntityCount.Count } diff --git a/aether-core/aether/backend/responsegenerator/indexgenerate.go b/aether-core/aether/backend/responsegenerator/indexgenerate.go index ea03308..8d09a17 100644 --- a/aether-core/aether/backend/responsegenerator/indexgenerate.go +++ b/aether-core/aether/backend/responsegenerator/indexgenerate.go @@ -10,6 +10,7 @@ import ( "aether-core/aether/services/globals" "aether-core/aether/services/logging" "aether-core/aether/services/toolbox" + // "aether-core/aether/services/randomhashgen" // "encoding/json" // "errors" @@ -92,28 +93,28 @@ func createUnbakedIndexes(fullData *[]api.Response) *api.Response { fd := *fullData var resp api.Response if len(fd) > 0 { - for i, _ := range fd { + for i := range fd { // For each Api.Response page if len(fd[i].Boards) > 0 { - for j, _ := range fd[i].Boards { + for j := range fd[i].Boards { entityIndex := createBoardIndex(&fd[i].Boards[j], i) resp.BoardIndexes = append(resp.BoardIndexes, entityIndex) } } if len(fd[i].Threads) > 0 { - for j, _ := range fd[i].Threads { + for j := range fd[i].Threads { entityIndex := createThreadIndex(&fd[i].Threads[j], i) resp.ThreadIndexes = append(resp.ThreadIndexes, entityIndex) } } if len(fd[i].Posts) > 0 { - for j, _ := range fd[i].Posts { + for j := range fd[i].Posts { entityIndex := createPostIndex(&fd[i].Posts[j], i) resp.PostIndexes = append(resp.PostIndexes, entityIndex) } } if len(fd[i].Votes) > 0 { - for j, _ := range fd[i].Votes { + for j := range fd[i].Votes { entityIndex := createVoteIndex(&fd[i].Votes[j], i) resp.VoteIndexes = append(resp.VoteIndexes, entityIndex) } @@ -121,13 +122,13 @@ func createUnbakedIndexes(fullData *[]api.Response) *api.Response { // Addresses: Address doesn't have an index form. It is its own index. // Addresses are skipped here. if len(fd[i].Keys) > 0 { - for j, _ := range fd[i].Keys { + for j := range fd[i].Keys { entityIndex := createKeyIndex(&fd[i].Keys[j], i) resp.KeyIndexes = append(resp.KeyIndexes, entityIndex) } } if len(fd[i].Truststates) > 0 { - for j, _ := range fd[i].Truststates { + for j := range fd[i].Truststates { entityIndex := createTruststateIndex(&fd[i].Truststates[j], i) resp.TruststateIndexes = append(resp.TruststateIndexes, entityIndex) } diff --git a/aether-core/aether/backend/responsegenerator/mainentitygenerate.go b/aether-core/aether/backend/responsegenerator/mainentitygenerate.go index 1e209c0..e6a0d20 100644 --- a/aether-core/aether/backend/responsegenerator/mainentitygenerate.go +++ b/aether-core/aether/backend/responsegenerator/mainentitygenerate.go @@ -10,6 +10,7 @@ import ( // "aether-core/aether/services/configstore" "aether-core/aether/services/globals" "aether-core/aether/services/logging" + // "aether-core/aether/services/randomhashgen" "aether-core/aether/services/toolbox" // "encoding/json" @@ -37,7 +38,7 @@ func bakeEntityPages(resultPages *[]api.ApiResponse, entityCounts *[]api.EntityC } // responsedir := fmt.Sprint(globals.BackendConfig.GetCachesDirectory(), "/",protv,"/responses/", foldername) toolbox.CreatePath(responsedir) - for i, _ := range *resultPages { + for i := range *resultPages { // entityType := findEntityInApiResponse((*resultPages)[i], entityType) // Set timestamp, number of items in it, total page count, and which page, filters. if filters != nil { diff --git a/aether-core/aether/backend/responsegenerator/manifestgenerate.go b/aether-core/aether/backend/responsegenerator/manifestgenerate.go index cbaa754..569a70d 100644 --- a/aether-core/aether/backend/responsegenerator/manifestgenerate.go +++ b/aether-core/aether/backend/responsegenerator/manifestgenerate.go @@ -49,7 +49,7 @@ type unbakedManifestCarrier struct { // pgNoExistsInSlice looks whether a certain page number was ever created in this manifest slice. This isn't super efficient, but also not a hot path. Page numbers rarely go above 1000. func pgNoExistsInSlice(pgNo uint64, slc *[]api.PageManifest) int { - for i, _ := range *slc { + for i := range *slc { if (*slc)[i].Page == pgNo { return i } @@ -78,7 +78,7 @@ func addToPageManifestSlice(pmans *[]api.PageManifest, item *unbakedManifestItem func constructManifestStructure(items *[]unbakedManifestItem) *[]api.PageManifest { var pmans []api.PageManifest - for i, _ := range *items { + for i := range *items { addToPageManifestSlice(&pmans, &(*items)[i]) } return &pmans @@ -87,23 +87,23 @@ func constructManifestStructure(items *[]unbakedManifestItem) *[]api.PageManifes // createUnbakedManifests returns a unbakedManifestCarrier because manifest is a two-level deep entity. It looks something like page:0 > manifest manifest manifest, page:1 > manifest manifest manifest. If you use the top level page count as the page border, it is useless because they can carry arbitrary amounts of data. Instead, we need to count manifests, split to pages based on manifest counts, and THEN bundle them up to page:0 > ... structure which is the final structure. func createUnbakedManifests(fullData *[]api.Response) *unbakedManifestCarrier { umc := unbakedManifestCarrier{} - for i, _ := range *fullData { - for j, _ := range (*fullData)[i].Boards { + for i := range *fullData { + for j := range (*fullData)[i].Boards { umc.BoardManifests = append(umc.BoardManifests, createUnbakedManifestItem(&(*fullData)[i].Boards[j], uint64(i))) } - for j, _ := range (*fullData)[i].Threads { + for j := range (*fullData)[i].Threads { umc.ThreadManifests = append(umc.ThreadManifests, createUnbakedManifestItem(&(*fullData)[i].Threads[j], uint64(i))) } - for j, _ := range (*fullData)[i].Posts { + for j := range (*fullData)[i].Posts { umc.PostManifests = append(umc.PostManifests, createUnbakedManifestItem(&(*fullData)[i].Posts[j], uint64(i))) } - for j, _ := range (*fullData)[i].Votes { + for j := range (*fullData)[i].Votes { umc.VoteManifests = append(umc.VoteManifests, createUnbakedManifestItem(&(*fullData)[i].Votes[j], uint64(i))) } - for j, _ := range (*fullData)[i].Keys { + for j := range (*fullData)[i].Keys { umc.KeyManifests = append(umc.KeyManifests, createUnbakedManifestItem(&(*fullData)[i].Keys[j], uint64(i))) } - for j, _ := range (*fullData)[i].Truststates { + for j := range (*fullData)[i].Truststates { umc.TruststateManifests = append(umc.TruststateManifests, createUnbakedManifestItem(&(*fullData)[i].Truststates[j], uint64(i))) } // for j, _ := range (*fullData)[i].Addresses { diff --git a/aether-core/aether/backend/responsegenerator/postrespgenerator.go b/aether-core/aether/backend/responsegenerator/postrespgenerator.go index 809bb7b..3407866 100644 --- a/aether-core/aether/backend/responsegenerator/postrespgenerator.go +++ b/aether-core/aether/backend/responsegenerator/postrespgenerator.go @@ -210,14 +210,14 @@ func GeneratePOSTResponse(respType string, req api.ApiResponse) ([]byte, error) indexes := createUnbakedIndexes(pages) indexPages := splitEntitiesToPages(indexes) indexApiResponse := convertResponsesToApiResponses(indexPages) - for key, _ := range *indexApiResponse { + for key := range *indexApiResponse { (*indexApiResponse)[key].Endpoint = fmt.Sprintf("%s_index_post", (*indexApiResponse)[key].Entity) } // Generate manifest manifest := createUnbakedManifests(pages) manifestPages := splitManifestToPages(manifest) manifestApiResponse := convertResponsesToApiResponses(manifestPages) - for key, _ := range *manifestApiResponse { + for key := range *manifestApiResponse { (*manifestApiResponse)[key].Endpoint = "manifest_post" } // bakeFinalPOSTApiResponse wraps the data up and assigns proper metadata. It does not pull any further data in. @@ -303,7 +303,7 @@ func insertIntoPOSTResponseReuseTracker(resultPage *api.ApiResponse, foldername func generateResultCachesFromPostRespChain(chain []configstore.POSTResponseEntry) []api.ResultCache { var rcachs []api.ResultCache - for i, _ := range chain { + for i := range chain { rcachs = append(rcachs, constructResultCache( api.Timestamp(chain[i].StartsFrom), api.Timestamp(chain[i].EndsAt), chain[i].ResponseUrl)) diff --git a/aether-core/aether/backend/responsegenerator/responsegenerator.go b/aether-core/aether/backend/responsegenerator/responsegenerator.go index 7431ae0..60e95ac 100644 --- a/aether-core/aether/backend/responsegenerator/responsegenerator.go +++ b/aether-core/aether/backend/responsegenerator/responsegenerator.go @@ -7,9 +7,11 @@ import ( // "fmt" "aether-core/aether/io/api" "aether-core/aether/io/persistence" + // "aether-core/aether/services/configstore" "aether-core/aether/services/globals" "aether-core/aether/services/logging" + // "aether-core/aether/services/randomhashgen" // "aether-core/aether/services/toolbox" // "encoding/json" @@ -77,7 +79,7 @@ func convertResponsesToApiResponses(r *[]api.Response) *[]api.ApiResponse { if r == nil { return &responses } - for i, _ := range *r { + for i := range *r { resp := api.ApiResponse{} resp.Prefill() // resp := GeneratePrefilledApiResponse() @@ -247,7 +249,7 @@ func constructResultCache(beg api.Timestamp, end api.Timestamp, url string) api. // sanitiseOutboundAddresses removes untrusted address data from the addresses destined to go out of this node. The remote node will also remove it, but there is no reason to leak information unnecessarily. func sanitiseOutboundAddresses(addrsPtr *[]api.Address) *[]api.Address { addrs := *addrsPtr - for key, _ := range addrs { + for key := range addrs { addrs[key].LocationType = 0 addrs[key].Type = 0 addrs[key].LastSuccessfulPing = 0 diff --git a/aether-core/aether/backend/responsegenerator/splitter.go b/aether-core/aether/backend/responsegenerator/splitter.go index 28ab7a0..4a3933b 100644 --- a/aether-core/aether/backend/responsegenerator/splitter.go +++ b/aether-core/aether/backend/responsegenerator/splitter.go @@ -27,17 +27,19 @@ splitManifestToPages is split off from the main entity splitter because manifest In other words, manifest structure is: responsebody > - posts_manifest > - page:0 > - m1, m2, m3 - page:1 > - m4,m5,m6 .. + + posts_manifest > + page:0 > + m1, m2, m3 + page:1 > + m4,m5,m6 .. while others are: responsebody > - posts > - e1, e2, e3 ... + + posts > + e1, e2, e3 ... This means if we count the first level entity count as a page splitting gate, it's not gonna work. We need to count manifests themselves. We can do this based on the manifests and try to figure out which page to put each page:0 item, but that's going to be wonky. In the default case it might not matter, but in the case where somebody breaks the config in a way that the page entity counts are vastly higher than the manifest counts (i.e. entity page takes 60k items while manifest takes 30k items) it might cause weird manifest sizings. @@ -78,7 +80,7 @@ func splitManifestToPages(fullData *unbakedManifestCarrier) *[]api.Response { entityTypes = append(entityTypes, "blankpage") // Why? because we still want to generate a blank manifest page if there is nothing inside, to communicate that this cache is empty. } - for i, _ := range entityTypes { + for i := range entityTypes { if entityTypes[i] == "boardmanifests" { dataSet := fullData.BoardManifests pageSize := globals.BackendConfig.GetEntityPageSizes().BoardManifests @@ -277,7 +279,7 @@ func splitEntitiesToPages(fullData *api.Response) *[]api.Response { var pages []api.Response // This is a lot of copy paste. This is because there is no automatic conversion from []api.Boards being recognised as []api.Provable. Without that, I have to convert them explicitly to be able to put them into a map[string:struct] which is a lot of extra work - more work than copy paste. - for i, _ := range entityTypes { + for i := range entityTypes { if entityTypes[i] == "boards" { dataSet := fullData.Boards pageSize := globals.BackendConfig.GetEntityPageSizes().Boards diff --git a/aether-core/aether/backend/swarmtest/main.go b/aether-core/aether/backend/swarmtest/main.go index 22db082..9340c99 100644 --- a/aether-core/aether/backend/swarmtest/main.go +++ b/aether-core/aether/backend/swarmtest/main.go @@ -393,7 +393,7 @@ func main() { // For each node that we have requested nodes := generateSwarmNames() // spew.Dump(ports.GetFreePorts(100)) - for i, _ := range nodes { + for i := range nodes { generateNodeData(&nodes[i]) serverInstance := startServingStaticNodeAsDataDonor(nodes[i]) insertDataIntoBackendNodeInstance(nodes[i]) diff --git a/aether-core/aether/backend/swarmtest/simplemetricsserver/simplemetricsserver.go b/aether-core/aether/backend/swarmtest/simplemetricsserver/simplemetricsserver.go index 760291a..ec317c1 100644 --- a/aether-core/aether/backend/swarmtest/simplemetricsserver/simplemetricsserver.go +++ b/aether-core/aether/backend/swarmtest/simplemetricsserver/simplemetricsserver.go @@ -257,7 +257,7 @@ func ProcessConnectionStates(rawData []pb.ConnState, rawDbStateData []pb.DbState n.Connections = append(n.Connections, connConvert(*val.Connection)) finalData.AddNode(n) } - for key, _ := range finalData.Nodes { + for key := range finalData.Nodes { // Get Db Size. fi, _ := os.Stat(filepath.Join("/Users/Helios/Library/Application Support/Air Labs", finalData.Nodes[key].Name, "backend/AetherDB.db")) // get the size diff --git a/aether-core/aether/frontend/beapiconsumer/caching.go b/aether-core/aether/frontend/beapiconsumer/caching.go index b93d1dd..2bf3cfc 100644 --- a/aether-core/aether/frontend/beapiconsumer/caching.go +++ b/aether-core/aether/frontend/beapiconsumer/caching.go @@ -80,16 +80,16 @@ func DetermineObservableUniverse() map[string]map[string]bool { ou := make(map[string]map[string]bool) // Determine observable universe for: boards boardFps := make(map[string]bool) - for k, _ := range cache.Boards { + for k := range cache.Boards { boardFps[cache.Boards[k].GetProvable().GetFingerprint()] = true } - for k, _ := range cache.Threads { + for k := range cache.Threads { boardFps[cache.Threads[k].GetBoard()] = true } - for k, _ := range cache.Posts { + for k := range cache.Posts { boardFps[cache.Posts[k].GetBoard()] = true } - for k, _ := range cache.Votes { + for k := range cache.Votes { boardFps[cache.Votes[k].GetBoard()] = true } // What's not included: keys that create the boards, and truststates that point to those keys. (I.e. if a board owner gets a 'member' badge in orange it won't automatically trigger a wholesale board update.) This is mostly for efficiency reasons, since boards can have an arbitrary number of board owners and elected mods. @@ -122,10 +122,10 @@ func DetermineObservableUniverse() map[string]map[string]bool { // FUTURE: if we need this, implement it here // Determine observable universe for: keys keyFps := make(map[string]bool) - for k, _ := range cache.Keys { + for k := range cache.Keys { keyFps[cache.Keys[k].GetProvable().GetFingerprint()] = true } - for k, _ := range cache.Truststates { + for k := range cache.Truststates { keyFps[cache.Truststates[k].GetTarget()] = true } ou["Keys"] = keyFps @@ -274,7 +274,7 @@ type cacheQuery struct { func queryBoardsCache(q cacheQuery) []*mimapi.Board { var result []*mimapi.Board - for k, _ := range cache.Boards { + for k := range cache.Boards { // Fingerprints range checker if !fingerprintsFilter(cache.Boards[k].GetProvable().GetFingerprint(), q.Fingerprints) { continue @@ -286,7 +286,7 @@ func queryBoardsCache(q cacheQuery) []*mimapi.Board { func queryThreadsCache(q cacheQuery) []*mimapi.Thread { var result []*mimapi.Thread - for k, _ := range cache.Threads { + for k := range cache.Threads { // Fingerprints range checker if !fingerprintsFilter(cache.Threads[k].GetProvable().GetFingerprint(), q.Fingerprints) { continue @@ -301,7 +301,7 @@ func queryThreadsCache(q cacheQuery) []*mimapi.Thread { func queryPostsCache(q cacheQuery) []*mimapi.Post { var result []*mimapi.Post - for k, _ := range cache.Posts { + for k := range cache.Posts { // Fingerprints range checker if !fingerprintsFilter(cache.Posts[k].GetProvable().GetFingerprint(), q.Fingerprints) { continue @@ -322,7 +322,7 @@ func queryPostsCache(q cacheQuery) []*mimapi.Post { func queryVotesCache(q cacheQuery, parentType string) []*mimapi.Vote { var result []*mimapi.Vote - for k, _ := range cache.Votes { + for k := range cache.Votes { // Fingerprints range checker if !fingerprintsFilter(cache.Votes[k].GetProvable().GetFingerprint(), q.Fingerprints) { continue @@ -361,7 +361,7 @@ func queryVotesCache(q cacheQuery, parentType string) []*mimapi.Vote { func queryKeysCache(q cacheQuery) []*mimapi.Key { var result []*mimapi.Key - for k, _ := range cache.Keys { + for k := range cache.Keys { // Fingerprints range checker if !fingerprintsFilter(cache.Keys[k].GetProvable().GetFingerprint(), q.Fingerprints) { continue @@ -373,7 +373,7 @@ func queryKeysCache(q cacheQuery) []*mimapi.Key { func queryTruststatesCache(q cacheQuery) []*mimapi.Truststate { var result []*mimapi.Truststate - for k, _ := range cache.Truststates { + for k := range cache.Truststates { // Fingerprints range checker if !fingerprintsFilter(cache.Truststates[k].GetProvable().GetFingerprint(), q.Fingerprints) { continue diff --git a/aether-core/aether/frontend/beapiconsumer/validation.go b/aether-core/aether/frontend/beapiconsumer/validation.go index 26b7e64..fea5091 100644 --- a/aether-core/aether/frontend/beapiconsumer/validation.go +++ b/aether-core/aether/frontend/beapiconsumer/validation.go @@ -7,7 +7,7 @@ import ( func validateBoards(eSet []*pbstructs.Board) []*pbstructs.Board { var valids []*pbstructs.Board - for k, _ := range eSet { + for k := range eSet { if boardValid(eSet[k]) { valids = append(valids, eSet[k]) } @@ -18,7 +18,7 @@ func validateBoards(eSet []*pbstructs.Board) []*pbstructs.Board { func validateThreads(eSet []*pbstructs.Thread) []*pbstructs.Thread { var valids []*pbstructs.Thread - for k, _ := range eSet { + for k := range eSet { if threadValid(eSet[k]) { valids = append(valids, eSet[k]) } @@ -29,7 +29,7 @@ func validateThreads(eSet []*pbstructs.Thread) []*pbstructs.Thread { func validatePosts(eSet []*pbstructs.Post) []*pbstructs.Post { var valids []*pbstructs.Post - for k, _ := range eSet { + for k := range eSet { if postValid(eSet[k]) { valids = append(valids, eSet[k]) } @@ -40,7 +40,7 @@ func validatePosts(eSet []*pbstructs.Post) []*pbstructs.Post { func validateVotes(eSet []*pbstructs.Vote) []*pbstructs.Vote { var valids []*pbstructs.Vote - for k, _ := range eSet { + for k := range eSet { if voteValid(eSet[k]) { valids = append(valids, eSet[k]) } @@ -51,7 +51,7 @@ func validateVotes(eSet []*pbstructs.Vote) []*pbstructs.Vote { func validateKeys(eSet []*pbstructs.Key) []*pbstructs.Key { var valids []*pbstructs.Key - for k, _ := range eSet { + for k := range eSet { if keyValid(eSet[k]) { valids = append(valids, eSet[k]) } @@ -62,7 +62,7 @@ func validateKeys(eSet []*pbstructs.Key) []*pbstructs.Key { func validateTruststates(eSet []*pbstructs.Truststate) []*pbstructs.Truststate { var valids []*pbstructs.Truststate - for k, _ := range eSet { + for k := range eSet { if truststateValid(eSet[k]) { valids = append(valids, eSet[k]) } diff --git a/aether-core/aether/frontend/clapiconsumer/clapiconsumer.go b/aether-core/aether/frontend/clapiconsumer/clapiconsumer.go index 0d71c3b..39fe5f5 100644 --- a/aether-core/aether/frontend/clapiconsumer/clapiconsumer.go +++ b/aether-core/aether/frontend/clapiconsumer/clapiconsumer.go @@ -195,7 +195,7 @@ func PushLocalUserAmbient() { return } u := festructs.CompiledUser{} - for key, _ := range uh.Users { + for key := range uh.Users { if uh.Users[key].Fingerprint == fp { u = uh.Users[key] } @@ -235,7 +235,7 @@ func SendHomeView() { } var thr []*feobjects.CompiledThreadEntity - for k, _ := range hvc.Threads { + for k := range hvc.Threads { thr = append(thr, hvc.Threads[k].Protobuf()) } hvp := pb.HomeViewPayload{Threads: thr} @@ -260,7 +260,7 @@ func SendPopularView() { } var thr []*feobjects.CompiledThreadEntity - for k, _ := range hvc.Threads { + for k := range hvc.Threads { thr = append(thr, hvc.Threads[k].Protobuf()) } hvp := pb.PopularViewPayload{Threads: thr} @@ -285,7 +285,7 @@ func SendNewView() { } var thrs []*feobjects.CompiledThreadEntity - for k, _ := range nvc.Threads { + for k := range nvc.Threads { protoEntity := nvc.Threads[k].Protobuf() // Get board name for thread ab := festructs.AmbientBoard{} @@ -300,7 +300,7 @@ func SendNewView() { } var psts []*feobjects.CompiledPostEntity - for k, _ := range nvc.Posts { + for k := range nvc.Posts { protoEntity := nvc.Posts[k].Protobuf() // Get board name for post ab := festructs.AmbientBoard{} @@ -438,7 +438,7 @@ func SendSearchResult(searchType, searchQuery string) { logging.Logf(1, "This search errored out. Type: %v, Query: %v, Error: %v", searchType, searchQuery, err) } resp.Boards = r.Protobuf() - for k, _ := range resp.Boards { + for k := range resp.Boards { subbed, notify, lastseen := globals.FrontendConfig.ContentRelations.IsSubbedBoard(resp.Boards[k].Fingerprint) whitelisted := globals.FrontendConfig.ContentRelations.SFWList.IsSFWListedBoard(resp.Boards[k].Fingerprint) resp.Boards[k].Subscribed = subbed @@ -455,7 +455,7 @@ func SendSearchResult(searchType, searchQuery string) { resp.Threads = threads.Protobuf() resp.Posts = posts.Protobuf() // Add whitelist data and board name, search score to the threads - for k, _ := range resp.Threads { + for k := range resp.Threads { resp.Threads[k].ViewMeta_SFWListed = globals.FrontendConfig.ContentRelations.SFWList.IsSFWListedBoard(resp.Threads[k].Board) ab := festructs.AmbientBoard{} logging.Logf(3, "Single read happens in SendSearchResult>One>Thread>Board") @@ -469,7 +469,7 @@ func SendSearchResult(searchType, searchQuery string) { } // Add whitelist data and scores to the posts - for k, _ := range resp.Posts { + for k := range resp.Posts { resp.Posts[k].ViewMeta_SFWListed = globals.FrontendConfig.ContentRelations.SFWList.IsSFWListedBoard(resp.Posts[k].Board) // Get board name ab := festructs.AmbientBoard{} @@ -498,7 +498,7 @@ func SendSearchResult(searchType, searchQuery string) { } resp.Users = r.Protobuf() // Add whitelist data and scores to the posts - for k, _ := range resp.Users { + for k := range resp.Users { resp.Users[k].ViewMeta_SearchScore = scoreMap[resp.Users[k].Fingerprint] } default: diff --git a/aether-core/aether/frontend/feapiserver/srvmethods.go b/aether-core/aether/frontend/feapiserver/srvmethods.go index 0c99535..9053360 100644 --- a/aether-core/aether/frontend/feapiserver/srvmethods.go +++ b/aether-core/aether/frontend/feapiserver/srvmethods.go @@ -61,7 +61,7 @@ func (s *server) GetThreadAndPosts(ctx context.Context, req *pb.ThreadAndPostsRe logging.Logf(1, "Getting BoardCarrier for in GetThreadAndPosts encountered an error. Error: %v", err) } b := festructs.CompiledBoard{} - for key, _ := range bc.Boards { + for key := range bc.Boards { if bc.Boards[key].Fingerprint == fp { b = bc.Boards[key] } @@ -97,7 +97,7 @@ func (s *server) GetBoardAndThreads(ctx context.Context, req *pb.BoardAndThreads logging.Logf(1, "Getting BoardCarrier for in GetBoardAndThreads encountered an error. Error: %v", err) } b := festructs.CompiledBoard{} - for key, _ := range bc.Boards { + for key := range bc.Boards { if bc.Boards[key].Fingerprint == fp { b = bc.Boards[key] } @@ -111,7 +111,7 @@ func (s *server) GetBoardAndThreads(ctx context.Context, req *pb.BoardAndThreads resp.Board.LastSeen = lastseen threads := festructs.CThreadBatch{} - for k1, _ := range bc.Threads { + for k1 := range bc.Threads { // Filter out the moddeletes / modapprovals based on the ruleset. if bc.Threads[k1].Board == fp { if bc.Threads[k1].CompiledContentSignals.ModApproved || bc.Threads[k1].CompiledContentSignals.SelfModApproved { @@ -132,7 +132,7 @@ func (s *server) GetBoardAndThreads(ctx context.Context, req *pb.BoardAndThreads // Convert all threads to protos var tprotos []*feobjects.CompiledThreadEntity - for k, _ := range threads { + for k := range threads { tprotos = append(tprotos, threads[k].Protobuf()) } resp.Threads = tprotos @@ -151,8 +151,8 @@ func (s *server) GetAllBoards(ctx context.Context, req *pb.AllBoardsRequest) (*p } cb := festructs.CBoardBatch{} - for key, _ := range boards { - for k2, _ := range boards[key].Boards { + for key := range boards { + for k2 := range boards[key].Boards { item := boards[key].Boards[k2] cb = append(cb, item) } @@ -160,7 +160,7 @@ func (s *server) GetAllBoards(ctx context.Context, req *pb.AllBoardsRequest) (*p cb.SortByThreadsCount() var cproto []*feobjects.CompiledBoardEntity - for k, _ := range cb { + for k := range cb { item := cb[k].Protobuf() cproto = append(cproto, item) subbed, notify, lastseen := globals.FrontendConfig.ContentRelations.IsSubbedBoard(item.Fingerprint) @@ -227,7 +227,7 @@ func (s *server) GetUserAndGraph(ctx context.Context, req *pb.UserAndGraphReques logging.Logf(1, "Getting User Header Carrier for GetUserAndGraph encountered an error. Error: %v", err) } u := festructs.CompiledUser{} - for key, _ := range uh.Users { + for key := range uh.Users { if uh.Users[key].Fingerprint == fp { u = uh.Users[key] } @@ -462,16 +462,16 @@ func (s *server) RequestBoardReports(ctx context.Context, req *pb.BoardReportsRe } var rtes []*feobjects.ReportsTabEntry - for k, _ := range threadCarriers { + for k := range threadCarriers { // Get all reportes threads and posts in this thread carrier thrs := getReportedThreads(threadCarriers[k].Threads) psts := getReportedPosts(threadCarriers[k].Posts) // And convert them to ReportsTabEntries, then protobufs - for k2, _ := range thrs { + for k2 := range thrs { entry := festructs.NewReportsTabEntryFromThread(&thrs[k2]) rtes = append(rtes, entry.Protobuf()) } - for k3, _ := range psts { + for k3 := range psts { entry := festructs.NewReportsTabEntryFromPost(&psts[k3]) rtes = append(rtes, entry.Protobuf()) } @@ -486,7 +486,7 @@ func (s *server) RequestBoardReports(ctx context.Context, req *pb.BoardReportsRe func getReportedThreads(sl []festructs.CompiledThread) []festructs.CompiledThread { var reported []festructs.CompiledThread - for k, _ := range sl { + for k := range sl { if len(sl[k].CompiledContentSignals.Reports) > 0 && !sl[k].CompiledContentSignals.SelfModIgnored { reported = append(reported, sl[k]) } @@ -497,7 +497,7 @@ func getReportedThreads(sl []festructs.CompiledThread) []festructs.CompiledThrea func getReportedPosts(sl []festructs.CompiledPost) []festructs.CompiledPost { var reported []festructs.CompiledPost - for k, _ := range sl { + for k := range sl { if len(sl[k].CompiledContentSignals.Reports) > 0 && !sl[k].CompiledContentSignals.SelfModIgnored { reported = append(reported, sl[k]) } @@ -515,16 +515,16 @@ func (s *server) RequestBoardModActions(ctx context.Context, req *pb.BoardModAct } var rtes []*feobjects.ModActionsTabEntry - for k, _ := range threadCarriers { + for k := range threadCarriers { // Get all ModActioned threads and posts in this thread carrier thrs := getModActionedThreads(threadCarriers[k].Threads) psts := getModActionedPosts(threadCarriers[k].Posts) // And convert them to ModActionsTabEntries, then protobufs - for k2, _ := range thrs { + for k2 := range thrs { entry := festructs.NewModActionsTabEntryFromThread(&thrs[k2]) rtes = append(rtes, entry.Protobuf()) } - for k3, _ := range psts { + for k3 := range psts { entry := festructs.NewModActionsTabEntryFromPost(&psts[k3]) rtes = append(rtes, entry.Protobuf()) } @@ -540,7 +540,7 @@ func (s *server) RequestBoardModActions(ctx context.Context, req *pb.BoardModAct func getModActionedThreads(sl []festructs.CompiledThread) []festructs.CompiledThread { var modBlocked []festructs.CompiledThread - for k, _ := range sl { + for k := range sl { if len(sl[k].CompiledContentSignals.ModBlocks) > 0 && !sl[k].CompiledContentSignals.SelfModIgnored { modBlocked = append(modBlocked, sl[k]) } @@ -551,7 +551,7 @@ func getModActionedThreads(sl []festructs.CompiledThread) []festructs.CompiledTh func getModActionedPosts(sl []festructs.CompiledPost) []festructs.CompiledPost { var modBlocked []festructs.CompiledPost - for k, _ := range sl { + for k := range sl { if len(sl[k].CompiledContentSignals.ModBlocks) > 0 && !sl[k].CompiledContentSignals.SelfModIgnored { modBlocked = append(modBlocked, sl[k]) } diff --git a/aether-core/aether/frontend/festructs/ambients.go b/aether-core/aether/frontend/festructs/ambients.go index 2f7b8d6..a8ffd14 100644 --- a/aether-core/aether/frontend/festructs/ambients.go +++ b/aether-core/aether/frontend/festructs/ambients.go @@ -50,7 +50,7 @@ type AmbientBoardBatch struct { func (b *AmbientBoardBatch) UpdateBatch(abs []AmbientBoard) { b.lock.Lock() defer b.lock.Unlock() - for key, _ := range abs { + for key := range abs { if loc := b.Find(abs[key]); loc != -1 { // AB already exists, update last updated timestamp // Heads up: board name can't change, that's why we don't have it here. @@ -65,7 +65,7 @@ func (b *AmbientBoardBatch) UpdateBatch(abs []AmbientBoard) { } func (b *AmbientBoardBatch) Find(ab AmbientBoard) int { - for key, _ := range b.Boards { + for key := range b.Boards { if b.Boards[key].Fingerprint == ab.Fingerprint { return key } @@ -81,7 +81,7 @@ func (b *AmbientBoardBatch) Save() { return } defer tx.Rollback() - for key, _ := range b.Boards { + for key := range b.Boards { err := tx.Save(&b.Boards[key]) if err != nil { logging.Logf(1, "AmbientBoardBatch add board to transaction failed. Error: %#v", err) @@ -104,7 +104,7 @@ func GetCurrentAmbients() *AmbientBoardBatch { logging.Logf(1, "Existing ambient board retrieval encountered an error. Err: %v", err) } var filteredAbs []AmbientBoard - for k, _ := range abs { + for k := range abs { subbed, notify, lastseen := globals.FrontendConfig.ContentRelations.IsSubbedBoard(abs[k].Fingerprint) if subbed { abs[k].Notify = notify diff --git a/aether-core/aether/frontend/festructs/batchactions.go b/aether-core/aether/frontend/festructs/batchactions.go index 7e4a111..8cd0156 100644 --- a/aether-core/aether/frontend/festructs/batchactions.go +++ b/aether-core/aether/frontend/festructs/batchactions.go @@ -9,7 +9,7 @@ import ( // GetAllBoards gets all boards within our observable universe. Observable universe is all entities that it could possibly be changed by the entities we have in this current bucket, at this single instant in time. func GetAllBoards(targetPtr *[]BoardCarrier, observableUniverse map[string]bool) error { var bc []BoardCarrier - for fp, _ := range observableUniverse { + for fp := range observableUniverse { b := BoardCarrier{} err := globals.KvInstance.One("Fingerprint", fp, &b) if err != nil { @@ -26,7 +26,7 @@ func GetAllBoards(targetPtr *[]BoardCarrier, observableUniverse map[string]bool) func GetAllUserHeaderCarriers(targetPtr *[]UserHeaderCarrier, observableUniverse map[string]bool) error { var uhcs []UserHeaderCarrier - for fp, _ := range observableUniverse { + for fp := range observableUniverse { uhc := UserHeaderCarrier{} err := globals.KvInstance.One("Fingerprint", fp, &uhc) if err != nil { diff --git a/aether-core/aether/frontend/festructs/carriers.go b/aether-core/aether/frontend/festructs/carriers.go index 8c2c256..d1810ad 100644 --- a/aether-core/aether/frontend/festructs/carriers.go +++ b/aether-core/aether/frontend/festructs/carriers.go @@ -138,14 +138,14 @@ func (c *BoardCarrier) RefreshWithoutSave(nowts int64) bool { c.generateSignalsTablesForThreadEntities() // pull in new changes to the thread entities and using the local scope user headers, refresh those. hasNewThreads := c.refreshThreadEntities(c.Boards.GetBoardSpecificUserHeaders()) - for k, _ := range c.Threads { + for k := range c.Threads { c.Threads[k].PostsCount = -1 } // -1 = No data, will be hidden in UI. If we end up compiling the underlying thread, that compilation process will provide the data upstream, and it'll be saved as such. c.applyMetas() c.LastReferenced = c.now // Save the number of posts. (Make sure that this is not based on incremental but on the total number of posts.) - for k, _ := range c.Boards { + for k := range c.Boards { if c.Boards[k].Fingerprint == c.Fingerprint { // Move compiled data that is needed on the client side to the compiled object so it can be transmitted over. c.Boards[k].ThreadsCount = len(c.Threads) @@ -178,7 +178,7 @@ func (c *BoardCarrier) refreshThreadEntities(boardSpecificUserHeaders CUserBatch c.Threads.Refresh(c.GetThreadsCATDs(), c.GetThreadsCFGs(), c.GetThreadsCMAs(), boardSpecificUserHeaders, c.now, c) // If there is a parent, then we've actually managed to find a thread entity, which means the thread entity actually exists, which means this is a valid container. c.WellFormed = true - for k, _ := range c.Threads { + for k := range c.Threads { if len(c.Threads[k].Fingerprint) == 0 { c.WellFormed = false break @@ -226,18 +226,18 @@ func (c *BoardCarrier) generateUserFingerprintsFromContent(nowts int64) []string ufps := make(map[string]bool) // Thread owners fps in delta nte := beapiconsumer.GetThreads(c.LastReferenced, nowts, []string{}, c.Fingerprint, false, false) - for k, _ := range nte { + for k := range nte { ufps[nte[k].GetOwner()] = true } // post owners' fps in delta npe := beapiconsumer.GetPosts(c.LastReferenced, nowts, []string{}, c.Fingerprint, "board", false, false) - for k, _ := range npe { + for k := range npe { ufps[npe[k].GetOwner()] = true } // Convert to slice var ufpsSlice []string - for key, _ := range ufps { + for key := range ufps { ufpsSlice = append(ufpsSlice, key) } return ufpsSlice @@ -250,9 +250,9 @@ func (c *BoardCarrier) getLocalDefaultMods() []string { // refreshLocalScopeUserHeadersWithLocalSignals refreshes the local signals of the user header entities brought forward in this specific delta. func (c *BoardCarrier) refreshLocalScopeUserHeadersWithLocalSignals() { // for every board in this board carrier - for k, _ := range c.Boards { + for k := range c.Boards { // Make it so that every user header is refreshed via the signals we have. We don't want to do a full insert - our headers' contents are already updated. - for j, _ := range c.Boards[k].LocalScopeUserHeaders { + for j := range c.Boards[k].LocalScopeUserHeaders { c.Boards[k].LocalScopeUserHeaders[j].RefreshUserSignals(&c.LSUHPublicTrusts, &c.LSUHCanonicalNames, &c.LSUHF451s, &c.LSUHPublicElects, c.getLocalDefaultMods(), c.Fingerprint, c.Statistics.UserCount) } } @@ -261,9 +261,9 @@ func (c *BoardCarrier) refreshLocalScopeUserHeadersWithLocalSignals() { // refreshLocalScopeUserHeadersWithGlobalUpdatesAndSignals refreshes the user headers in the local scope with the content and signals from the global scope. Since global scope user headers update ran before, by doing this, we don't have to pull updates from the backend again, the content will automatically update. By the virtue of that, the global signals within those entities will also be updated, making us ready for a delta insert of the local signals. func (c *BoardCarrier) refreshLocalScopeUserHeadersWithGlobalUpdatesAndSignals() { // for every board in this board carrier - for k, _ := range c.Boards { + for k := range c.Boards { // Make it so that every user header is refreshed via its global counterpart. - for j, _ := range c.Boards[k].LocalScopeUserHeaders { + for j := range c.Boards[k].LocalScopeUserHeaders { globalUserHeader := UserHeaderCarrier{} logging.Logf(3, "Single read happens in refreshLocalScopeUserHeadersWithGlobalUpdatesAndSignals>One") err := globals.KvInstance.One("Fingerprint", c.Boards[k].LocalScopeUserHeaders[j].Fingerprint, &globalUserHeader) @@ -292,27 +292,27 @@ func (c *BoardCarrier) generateNeededUserHeaderFingerprints() []string { This text is here because I just tried to add the thread and post owner fingerprints into this list before realising that it's a two-tier system. So this is not a bug. */ uhfps := make(map[string]bool) - for k, _ := range c.LSUHPublicTrusts { + for k := range c.LSUHPublicTrusts { uhfps[c.LSUHPublicTrusts[k].TargetFingerprint] = true } - for k, _ := range c.LSUHCanonicalNames { + for k := range c.LSUHCanonicalNames { uhfps[c.LSUHCanonicalNames[k].TargetFingerprint] = true } - for k, _ := range c.LSUHF451s { + for k := range c.LSUHF451s { uhfps[c.LSUHF451s[k].TargetFingerprint] = true } - for k, _ := range c.LSUHPublicElects { + for k := range c.LSUHPublicElects { uhfps[c.LSUHPublicElects[k].TargetFingerprint] = true } // Always add the fingerprints of the board's creator and boardowners assigned by it. dm := c.getLocalDefaultMods() - for k, _ := range dm { + for k := range dm { uhfps[dm[k]] = true } // Convert to slice var uhfpsSlice []string - for key, _ := range uhfps { + for key := range uhfps { uhfpsSlice = append(uhfpsSlice, key) } // logging.Logf(1, "For board %v, Length of needed user header fingerprints for board: %#v, These are the fps: %v", c.Fingerprint, len(uhfpsSlice), uhfpsSlice) @@ -329,7 +329,7 @@ func (c *BoardCarrier) refreshLSUserHeadersBucket(targetsfp []string, boardfp st } // For each target fp, make sure they either exist in our local set, or find it from the global set and add it to the local set. for _, targetfp := range targetsfp { - for k, _ := range b.LocalScopeUserHeaders { + for k := range b.LocalScopeUserHeaders { if b.LocalScopeUserHeaders[k].Fingerprint == targetfp { return // We have the uh in the board. No need to do anything. @@ -351,7 +351,7 @@ func (c *BoardCarrier) refreshLSUserHeadersBucket(targetsfp []string, boardfp st func (c *BoardCarrier) ConstructAmbientBoards(hasNewThreads bool, nowts int64) []AmbientBoard { var abs []AmbientBoard - for key, _ := range c.Boards { + for key := range c.Boards { abs = append(abs, c.Boards[key].ConvertToAmbientBoard(hasNewThreads, nowts)) } return abs @@ -366,7 +366,7 @@ func (c *BoardCarrier) GetTopThreadsForView(num int) *[]CompiledThread { foundCount := 0 var foundThr []CompiledThread - for k, _ := range c.Threads { + for k := range c.Threads { if foundCount > num { break } @@ -383,7 +383,7 @@ func (c *BoardCarrier) GetTopThreadsForView(num int) *[]CompiledThread { type BCBatch []BoardCarrier func (c *BCBatch) Find(fp string) int { - for k, _ := range *c { + for k := range *c { if (*c)[k].Fingerprint == fp { return k } @@ -399,7 +399,7 @@ func (c *BCBatch) Insert(newBoardEntities []*pbstructs.Board) { The issue with that is, when you have a 1:1 mapping between a carrier and a compiled item, that means your batch size for indexing will always be 1. This is not too big of an issue, it just makes indexing take a little longer — but in the case this starts to become a problem, we can always make it batch by re-enabling this. */ // toBeIndexed := CBoardBatch{} - for k, _ := range newBoardEntities { + for k := range newBoardEntities { if i := c.Find(newBoardEntities[k].GetProvable().GetFingerprint()); i != -1 { (*c)[i].Boards.InsertFromProtobuf([]*pbstructs.Board{newBoardEntities[k]}) // toBeIndexed = append(toBeIndexed, (*c)[i].Boards[0]) @@ -451,7 +451,7 @@ func (c *ThreadCarrier) refreshThreadEntities(boardSpecificUserHeaders CUserBatc c.Threads.Refresh(c.GetThreadsCATDs(), c.GetThreadsCFGs(), c.GetThreadsCMAs(), boardSpecificUserHeaders, c.now, bc) // If there is a parent, then we've actually managed to find a thread entity, which means the thread entity actually exists, which means this is a valid container. allWellFormed := true - for k, _ := range c.Threads { + for k := range c.Threads { if len(c.Threads[k].Fingerprint) == 0 { allWellFormed = false break @@ -484,7 +484,7 @@ func (c *ThreadCarrier) refreshPosts(boardSpecificUserHeaders CUserBatch, bc *Bo */ var postsDelta []CompiledPost - for k, _ := range newPostsInThread { + for k := range newPostsInThread { if i := c.Posts.Find(newPostsInThread[k].Provable.Fingerprint); i != -1 { postsDelta = append(postsDelta, c.Posts[i]) } @@ -503,7 +503,7 @@ func (c *ThreadCarrier) generateSignalsTablesForPostsInThread() { type postPool []*feobjects.CompiledPostEntity func (p *postPool) Find(fp string) int { - for k, _ := range *p { + for k := range *p { if (*p)[k].Fingerprint == fp { return k } @@ -522,7 +522,7 @@ func (p *postPool) Find(fp string) int { func (c *ThreadCarrier) MakeTree(showDeleted, showOrphans bool) *feobjects.CompiledThreadEntity { pool := postPool{} c.Posts.Sort() - for k, _ := range c.Posts { + for k := range c.Posts { if !showDeleted { // If deleted show is disabled, filter them out. if c.Posts[k].CompiledContentSignals.ModApproved || c.Posts[k].CompiledContentSignals.SelfModApproved { @@ -536,13 +536,13 @@ func (c *ThreadCarrier) MakeTree(showDeleted, showOrphans bool) *feobjects.Compi pool = append(pool, c.Posts[k].Protobuf()) } var thr *feobjects.CompiledThreadEntity - for k, _ := range c.Threads { + for k := range c.Threads { if c.Threads[k].Fingerprint == c.Fingerprint { thr = c.Threads[k].Protobuf() } } - for k, _ := range pool { + for k := range pool { // If exists in pool map it to the parent's children if i := pool.Find(pool[k].Parent); i != -1 { pool[i].Children = append(pool[i].Children, pool[k]) @@ -554,7 +554,7 @@ func (c *ThreadCarrier) MakeTree(showDeleted, showOrphans bool) *feobjects.Compi var orphans []*feobjects.CompiledPostEntity - for k, _ := range pool { + for k := range pool { if pool[k].GetParent() == c.Fingerprint { roots = append(roots, pool[k]) continue @@ -661,7 +661,7 @@ func (c *ThreadCarrier) Refresh(boardSpecificUserHeaders CUserBatch, bc *BoardCa // Set the last referenced to now, so next refresh will use it as a base. c.LastReferenced = c.now // Save the number of posts. (Make sure that this is not based on incremental but on the total number of posts.) - for k, _ := range c.Threads { + for k := range c.Threads { if c.Threads[k].Fingerprint == c.Fingerprint { c.Threads[k].PostsCount = len(c.Posts) } @@ -742,7 +742,7 @@ func (c *UserHeaderCarrier) refreshUserEntity(localDefaultMods []string, totalPo type UHCBatch []UserHeaderCarrier func (c *UHCBatch) Find(fp string) int { - for k, _ := range *c { + for k := range *c { if (*c)[k].Fingerprint == fp { return k } @@ -751,7 +751,7 @@ func (c *UHCBatch) Find(fp string) int { } func (c *UHCBatch) Refresh(localDefaultMods []string, totalPop int, nowts int64) { - for k, _ := range *c { + for k := range *c { u := (*c)[k] (&u).Refresh(localDefaultMods, totalPop, nowts) } @@ -832,7 +832,7 @@ func NewStatisticsCarrier(bloomsize uint) StatisticsCarrier { func (g *StatisticsCarrier) Refresh(newUserFingerprints []string) { // Put their fingerprints into the bloom - for k, _ := range newUserFingerprints { + for k := range newUserFingerprints { if len(newUserFingerprints[k]) > 0 { g.UserCountBloom.AddString(newUserFingerprints[k]) } @@ -867,7 +867,7 @@ func (g *GlobalStatisticsCarrier) Refresh(nowts int64) []*pbstructs.Key { var fps []string // Put their fingerprints into the bloom - for k, _ := range newUserEntities { + for k := range newUserEntities { if fp := newUserEntities[k].GetProvable().GetFingerprint(); len(fp) > 0 { fps = append(fps, fp) } diff --git a/aether-core/aether/frontend/festructs/festructs.go b/aether-core/aether/frontend/festructs/festructs.go index 38a1f8e..34b6cd3 100644 --- a/aether-core/aether/frontend/festructs/festructs.go +++ b/aether-core/aether/frontend/festructs/festructs.go @@ -61,9 +61,9 @@ func CommitSearchIndexes(wg *sync.WaitGroup) { ub = append(ub, CUserIndexCache) /* Commit board batches */ - for batchIndex, _ := range bb { + for batchIndex := range bb { ib := search.NewBatch() - for k, _ := range bb[batchIndex] { + for k := range bb[batchIndex] { ib.Index(bb[batchIndex][k].SearchId(), bb[batchIndex][k]) } err := search.CommitBatch(ib) @@ -73,9 +73,9 @@ func CommitSearchIndexes(wg *sync.WaitGroup) { } /* Commit thread batches */ - for batchIndex, _ := range tb { + for batchIndex := range tb { ib := search.NewBatch() - for k, _ := range tb[batchIndex] { + for k := range tb[batchIndex] { ib.Index(tb[batchIndex][k].SearchId(), tb[batchIndex][k]) } err := search.CommitBatch(ib) @@ -85,9 +85,9 @@ func CommitSearchIndexes(wg *sync.WaitGroup) { } /* Commit post batches */ - for batchIndex, _ := range pb { + for batchIndex := range pb { ib := search.NewBatch() - for k, _ := range pb[batchIndex] { + for k := range pb[batchIndex] { ib.Index(pb[batchIndex][k].SearchId(), pb[batchIndex][k]) } err := search.CommitBatch(ib) @@ -97,9 +97,9 @@ func CommitSearchIndexes(wg *sync.WaitGroup) { } /* Commit user batches */ - for batchIndex, _ := range ub { + for batchIndex := range ub { ib := search.NewBatch() - for k, _ := range ub[batchIndex] { + for k := range ub[batchIndex] { ib.Index(ub[batchIndex][k].SearchId(), ub[batchIndex][k]) } err := search.CommitBatch(ib) @@ -186,7 +186,7 @@ func (c *CompiledPost) RefreshContentSignals(catds *CATDBatch, cfgs *CFGBatch, c } func (c *CompiledPost) RefreshUserHeader(boardSpecificUserHeaders CUserBatch) { - for k, _ := range boardSpecificUserHeaders { + for k := range boardSpecificUserHeaders { if boardSpecificUserHeaders[k].Fingerprint == c.Owner.Fingerprint { c.Owner = boardSpecificUserHeaders[k] return @@ -262,10 +262,10 @@ func (c *CompiledPost) RefreshExogenousContentSignals(bc *BoardCarrier, tc *Thre /*---------- Modblock / modapprove state ----------*/ // Behaviour: if at least one modblock, block it, if there is at least one modapprove, unblock it. so if something is both modblocked and modapproved, it will be visible. // Approvals - for k, _ := range c.CompiledContentSignals.ModApprovals { + for k := range c.CompiledContentSignals.ModApprovals { sourcefp := c.CompiledContentSignals.ModApprovals[k].SourceFp b := &CompiledBoard{} - for k, _ := range bc.Boards { + for k := range bc.Boards { if bc.Boards[k].Fingerprint == bc.Fingerprint { b = &bc.Boards[k] } @@ -276,10 +276,10 @@ func (c *CompiledPost) RefreshExogenousContentSignals(bc *BoardCarrier, tc *Thre } } // Blocks - for k, _ := range c.CompiledContentSignals.ModBlocks { + for k := range c.CompiledContentSignals.ModBlocks { sourcefp := c.CompiledContentSignals.ModBlocks[k].SourceFp b := &CompiledBoard{} - for k, _ := range bc.Boards { + for k := range bc.Boards { if bc.Boards[k].Fingerprint == bc.Fingerprint { b = &bc.Boards[k] } @@ -325,7 +325,7 @@ type CPostBatch []CompiledPost // IndexForSearch adds all entities in this batch into the search index. func (batch *CPostBatch) IndexForSearch() { - for k, _ := range *batch { + for k := range *batch { CPostIndexCache = append(CPostIndexCache, (*batch)[k]) } // if len(*batch) == 0 { @@ -346,7 +346,7 @@ func (batch *CPostBatch) IndexForSearch() { func (batch *CPostBatch) Insert(ces []CompiledPost) { toBeIndexed := CPostBatch{} - for k, _ := range ces { + for k := range ces { i := batch.Find(ces[k].Fingerprint) if i != -1 { // Trigger insert. It'll only update if the lastupdate is newer. @@ -363,7 +363,7 @@ func (batch *CPostBatch) Insert(ces []CompiledPost) { func (batch *CPostBatch) InsertFromProtobuf(ces []*pbstructs.Post) { toBeIndexed := CPostBatch{} - for k, _ := range ces { + for k := range ces { if ces[k] == nil { continue } @@ -385,7 +385,7 @@ func (batch *CPostBatch) InsertFromProtobuf(ces []*pbstructs.Post) { } func (batch *CPostBatch) Find(postfp string) int { - for k, _ := range *batch { + for k := range *batch { if postfp == (*batch)[k].Fingerprint { return k } @@ -394,7 +394,7 @@ func (batch *CPostBatch) Find(postfp string) int { } func (batch *CPostBatch) Refresh(catds *CATDBatch, cfgs *CFGBatch, cmas *CMABatch, boardSpecificUserHeaders CUserBatch, nowts int64, bc *BoardCarrier, tc *ThreadCarrier) { - for k, _ := range *batch { + for k := range *batch { (*batch)[k].Refresh(catds, cfgs, cmas, boardSpecificUserHeaders, nowts, bc, tc) } } @@ -415,7 +415,7 @@ func (batch *CPostBatch) Sort() { func (batch *CPostBatch) ToProtobuf() []*feobjects.CompiledPostEntity { var protos []*feobjects.CompiledPostEntity - for k, _ := range *batch { + for k := range *batch { p := (*batch)[k].Protobuf() protos = append(protos, p) } @@ -492,7 +492,7 @@ func (c *CompiledThread) RefreshContentSignals(catds *CATDBatch, cfgs *CFGBatch, // RefreshUserHeader needs board fingerprint because user signals within user headers are scoped, global scope is available to all and without a board fp, those don't depend on any board scope. But within the boards, there is a scope that is based on elections, assignments, people choosing to trust certain people as mods only within that board, and that scope needs to be applied over. func (c *CompiledThread) RefreshUserHeader(boardSpecificUserHeaders CUserBatch) { - for k, _ := range boardSpecificUserHeaders { + for k := range boardSpecificUserHeaders { if boardSpecificUserHeaders[k].Fingerprint == c.Owner.Fingerprint { c.Owner = boardSpecificUserHeaders[k] return @@ -581,10 +581,10 @@ func (c *CompiledThread) RefreshExogenousContentSignals(bc *BoardCarrier) { /*---------- Modblock / modapprove state ----------*/ // Behaviour: if at least one modblock, block it, if there is at least one modapprove, unblock it. so if something is both modblocked and modapproved, it will be visible. // Approvals - for k, _ := range c.CompiledContentSignals.ModApprovals { + for k := range c.CompiledContentSignals.ModApprovals { sourcefp := c.CompiledContentSignals.ModApprovals[k].SourceFp b := &CompiledBoard{} - for k, _ := range bc.Boards { + for k := range bc.Boards { if bc.Boards[k].Fingerprint == bc.Fingerprint { b = &bc.Boards[k] } @@ -595,10 +595,10 @@ func (c *CompiledThread) RefreshExogenousContentSignals(bc *BoardCarrier) { } } // Blocks - for k, _ := range c.CompiledContentSignals.ModBlocks { + for k := range c.CompiledContentSignals.ModBlocks { sourcefp := c.CompiledContentSignals.ModBlocks[k].SourceFp b := &CompiledBoard{} - for k, _ := range bc.Boards { + for k := range bc.Boards { if bc.Boards[k].Fingerprint == bc.Fingerprint { b = &bc.Boards[k] } @@ -616,7 +616,7 @@ type CThreadBatch []CompiledThread // IndexForSearch adds all entities in this batch into the search index. func (batch *CThreadBatch) IndexForSearch() { - for k, _ := range *batch { + for k := range *batch { CThreadIndexCache = append(CThreadIndexCache, (*batch)[k]) } @@ -638,7 +638,7 @@ func (batch *CThreadBatch) IndexForSearch() { func (batch *CThreadBatch) Insert(cthreads []CompiledThread) { toBeIndexed := CThreadBatch{} - for k, _ := range cthreads { + for k := range cthreads { i := batch.Find(cthreads[k].Fingerprint) if i != -1 { // Trigger insert. It'll only update if the lastupdate is newer. @@ -656,7 +656,7 @@ func (batch *CThreadBatch) Insert(cthreads []CompiledThread) { func (batch *CThreadBatch) InsertFromProtobuf(cthreads []*pbstructs.Thread) bool { var hasNewThreads bool toBeIndexed := CThreadBatch{} - for k, _ := range cthreads { + for k := range cthreads { if cthreads[k] == nil { continue } @@ -685,7 +685,7 @@ func (batch *CThreadBatch) InsertFromProtobuf(cthreads []*pbstructs.Thread) bool } func (batch *CThreadBatch) Find(threadfp string) int { - for k, _ := range *batch { + for k := range *batch { if threadfp == (*batch)[k].Fingerprint { return k } @@ -694,7 +694,7 @@ func (batch *CThreadBatch) Find(threadfp string) int { } func (batch *CThreadBatch) Refresh(catds *CATDBatch, cfgs *CFGBatch, cmas *CMABatch, boardSpecificUserHeaders CUserBatch, nowts int64, bc *BoardCarrier) { - for k, _ := range *batch { + for k := range *batch { (*batch)[k].Refresh(catds, cfgs, cmas, boardSpecificUserHeaders, nowts, bc) } } @@ -715,7 +715,7 @@ func (batch *CThreadBatch) SortByCreation() { func (batch *CThreadBatch) ToProtobuf() []*feobjects.CompiledThreadEntity { var protos []*feobjects.CompiledThreadEntity - for k, _ := range *batch { + for k := range *batch { p := (*batch)[k].Protobuf() protos = append(protos, p) } @@ -829,7 +829,7 @@ type CUserBatch []CompiledUser // IndexForSearch adds all entities in this batch into the search index. func (batch *CUserBatch) IndexForSearch() { - for k, _ := range *batch { + for k := range *batch { CUserIndexCache = append(CUserIndexCache, (*batch)[k]) } // if len(*batch) == 0 { @@ -850,7 +850,7 @@ func (batch *CUserBatch) IndexForSearch() { func (batch *CUserBatch) Insert(cusers []CompiledUser) { toBeIndexed := CUserBatch{} - for k, _ := range cusers { + for k := range cusers { i := batch.Find(cusers[k].Fingerprint) if i != -1 { // Trigger insert. It'll only update if the lastupdate is newer. @@ -866,7 +866,7 @@ func (batch *CUserBatch) Insert(cusers []CompiledUser) { } func (batch *CUserBatch) InsertWithSignalMerge(cusers []CompiledUser) { - for k, _ := range cusers { + for k := range cusers { i := batch.Find(cusers[k].Fingerprint) if i != -1 { // Trigger insert. It'll only update if the lastupdate is newer. @@ -881,7 +881,7 @@ func (batch *CUserBatch) InsertWithSignalMerge(cusers []CompiledUser) { func (batch *CUserBatch) InsertFromProtobuf(cusers []*pbstructs.Key, nowts int64) { toBeIndexed := CUserBatch{} - for k, _ := range cusers { + for k := range cusers { if cusers[k] == nil { continue } @@ -900,7 +900,7 @@ func (batch *CUserBatch) InsertFromProtobuf(cusers []*pbstructs.Key, nowts int64 } func (batch *CUserBatch) Find(userfp string) int { - for k, _ := range *batch { + for k := range *batch { if userfp == (*batch)[k].Fingerprint { return k } @@ -909,7 +909,7 @@ func (batch *CUserBatch) Find(userfp string) int { } func (batch *CUserBatch) Refresh(cpts *CPTBatch, ccns *CCNBatch, cf451s *CF451Batch, cpes *CPEBatch, localDefaultMods []string, domainfp string, totalPop int) { - for k, _ := range *batch { + for k := range *batch { (*batch)[k].Refresh(cpts, ccns, cf451s, cpes, localDefaultMods, domainfp, totalPop) } } @@ -969,7 +969,7 @@ func NewCBoard(rp *pbstructs.Board) CompiledBoard { Meta: rp.GetMeta(), } if bo := rp.GetBoardOwners(); len(bo) > 0 { - for k, _ := range bo { + for k := range bo { cb.BoardOwners = append(cb.BoardOwners, bo[k].GetKeyFingerprint()) } } @@ -979,7 +979,7 @@ func NewCBoard(rp *pbstructs.Board) CompiledBoard { // GetUserHeader attempts to get the local user header if available within that board scope, if not, it attempts to get the global user header, if present. func (cb *CompiledBoard) GetUserHeader(fp string) CompiledUser { - for k, _ := range cb.LocalScopeUserHeaders { + for k := range cb.LocalScopeUserHeaders { if cb.LocalScopeUserHeaders[k].Fingerprint == fp { return cb.LocalScopeUserHeaders[k] } @@ -1003,12 +1003,12 @@ func (cb *CompiledBoard) GetDefaultMods() []string { dm = append(dm, cb.BoardOwners...) // To map and back again to remove dedupes. m := make(map[string]bool) - for k, _ := range dm { + for k := range dm { m[dm[k]] = true } var result []string - for k, _ := range m { + for k := range m { result = append(result, k) } return result @@ -1024,7 +1024,7 @@ func (c *CompiledBoard) RefreshContentSignals(catds *CATDBatch, cfgs *CFGBatch, } func (c *CompiledBoard) RefreshUserHeader(boardSpecificUserHeaders CUserBatch) { - for k, _ := range boardSpecificUserHeaders { + for k := range boardSpecificUserHeaders { if boardSpecificUserHeaders[k].Fingerprint == c.Owner.Fingerprint { c.Owner = boardSpecificUserHeaders[k] return @@ -1095,10 +1095,10 @@ func (c *CompiledBoard) RefreshExogenousContentSignals(bc *BoardCarrier) { /*---------- Modblock / modapprove state ----------*/ // Behaviour: if at least one modblock, block it, if there is at least one modapprove, unblock it. so if something is both modblocked and modapproved, it will be visible. // Approvals - for k, _ := range c.CompiledContentSignals.ModApprovals { + for k := range c.CompiledContentSignals.ModApprovals { sourcefp := c.CompiledContentSignals.ModApprovals[k].SourceFp b := &CompiledBoard{} - for k, _ := range bc.Boards { + for k := range bc.Boards { if bc.Boards[k].Fingerprint == bc.Fingerprint { b = &bc.Boards[k] } @@ -1109,10 +1109,10 @@ func (c *CompiledBoard) RefreshExogenousContentSignals(bc *BoardCarrier) { } } // Blocks - for k, _ := range c.CompiledContentSignals.ModBlocks { + for k := range c.CompiledContentSignals.ModBlocks { sourcefp := c.CompiledContentSignals.ModBlocks[k].SourceFp b := &CompiledBoard{} - for k, _ := range bc.Boards { + for k := range bc.Boards { if bc.Boards[k].Fingerprint == bc.Fingerprint { b = &bc.Boards[k] } @@ -1128,7 +1128,7 @@ type CBoardBatch []CompiledBoard // IndexForSearch adds all entities in this batch into the search index. func (batch *CBoardBatch) IndexForSearch() { - for k, _ := range *batch { + for k := range *batch { CBoardIndexCache = append(CBoardIndexCache, (*batch)[k]) } // if len(*batch) == 0 { @@ -1149,7 +1149,7 @@ func (batch *CBoardBatch) IndexForSearch() { func (batch *CBoardBatch) Insert(cboards []CompiledBoard) { toBeIndexed := CBoardBatch{} - for k, _ := range cboards { + for k := range cboards { i := batch.Find(cboards[k].Fingerprint) if i != -1 { // Trigger insert. It'll only update if the lastupdate is newer. @@ -1166,7 +1166,7 @@ func (batch *CBoardBatch) Insert(cboards []CompiledBoard) { func (batch *CBoardBatch) InsertFromProtobuf(cboards []*pbstructs.Board) { toBeIndexed := CBoardBatch{} - for k, _ := range cboards { + for k := range cboards { if cboards[k] == nil { continue } @@ -1185,7 +1185,7 @@ func (batch *CBoardBatch) InsertFromProtobuf(cboards []*pbstructs.Board) { } func (batch *CBoardBatch) Find(boardfp string) int { - for k, _ := range *batch { + for k := range *batch { if boardfp == (*batch)[k].Fingerprint { return k } @@ -1194,14 +1194,14 @@ func (batch *CBoardBatch) Find(boardfp string) int { } func (batch *CBoardBatch) Refresh(catds *CATDBatch, cfgs *CFGBatch, cmas *CMABatch, boardSpecificUserHeaders CUserBatch, nowts int64, bc *BoardCarrier) { - for k, _ := range *batch { + for k := range *batch { (*batch)[k].Refresh(catds, cfgs, cmas, boardSpecificUserHeaders, nowts, bc) } } func (batch *CBoardBatch) GetDefaultMods() []string { var dms []string - for k, _ := range *batch { + for k := range *batch { dms = append(dms, (*batch)[k].GetDefaultMods()...) } return dms @@ -1209,7 +1209,7 @@ func (batch *CBoardBatch) GetDefaultMods() []string { func (batch *CBoardBatch) GetBoardSpecificUserHeaders() CUserBatch { b := CUserBatch{} - for k, _ := range *batch { + for k := range *batch { b = append(b, (*batch)[k].LocalScopeUserHeaders...) } return b @@ -1447,7 +1447,7 @@ func parsePublicElectByNetwork(targetfp string, totalPop int, cpe CompiledPE) (e func parseFollowerCount(targetfp string, cpt CompiledPT) int { var count int - for k, _ := range cpt.PTs { + for k := range cpt.PTs { if cpt.PTs[k].Fingerprint == targetfp && cpt.PTs[k].Type == Signal_Follow { count++ @@ -1457,7 +1457,7 @@ func parseFollowerCount(targetfp string, cpt CompiledPT) int { } func isF451Mod(targetfp string, cf451 CompiledF451) bool { - for k, _ := range cf451.F451s { + for k := range cf451.F451s { if cf451.F451s[k].TargetFingerprint == targetfp && ca.IsTrustedCAKeyByFp(cf451.F451s[k].SourceFingerprint) { return true } @@ -1466,7 +1466,7 @@ func isF451Mod(targetfp string, cf451 CompiledF451) bool { } func isModByDefault(targetfp string, localDefaultMods []string) bool { - for k, _ := range localDefaultMods { + for k := range localDefaultMods { if localDefaultMods[k] == targetfp { return true } @@ -1478,7 +1478,7 @@ func parseCanonicalName(ccn CompiledCN) (cname, cnamesource string) { highestPrioritySourceKey := -1 highestPrioritySoFar := 0 highestPrioritySet := false - for k, _ := range ccn.CNs { + for k := range ccn.CNs { isCaKey, priority := ca.IsTrustedCAKeyByFpWithPriority( ccn.CNs[k].SourceFingerprint) if isCaKey { @@ -1579,7 +1579,7 @@ func (s *CompiledContentSignals) Insert( cfg := (*cfgs)[i2] var expss []ExplainedSignal - for k, _ := range cfg.FGs { + for k := range cfg.FGs { expss = append(expss, cfg.FGs[k].CnvToExplainedSignal()) // if cfg.FGs[k].Self { // s.SelfReported = true @@ -1592,7 +1592,7 @@ func (s *CompiledContentSignals) Insert( i3 := cmas.Find(targetfp) if i3 != -1 { cma := (*cmas)[i3] - for k, _ := range cma.MAs { + for k := range cma.MAs { if cma.MAs[k].Type == Signal_ModBlock { s.ModBlocks = append( s.ModBlocks, cma.MAs[k].CnvToExplainedSignal()) @@ -1709,7 +1709,7 @@ func NewReportsTabEntryFromPost(e *CompiledPost) *ReportsTabEntry { func getNewestReportTimestamp(c *CompiledContentSignals) int64 { var newest int64 - for k, _ := range c.Reports { + for k := range c.Reports { if stamp := max(c.Reports[k].Creation, c.Reports[k].LastUpdate); stamp > newest { newest = stamp } @@ -1761,7 +1761,7 @@ func NewModActionsTabEntryFromPost(e *CompiledPost) *ModActionsTabEntry { // TODO handle modapprovals in the future as well, not just modblocks func getNewestModActionTimestamp(c *CompiledContentSignals) int64 { var newest int64 - for k, _ := range c.ModBlocks { + for k := range c.ModBlocks { if stamp := max(c.ModBlocks[k].Creation, c.ModBlocks[k].LastUpdate); stamp > newest { newest = stamp } diff --git a/aether-core/aether/frontend/festructs/notifications.go b/aether-core/aether/frontend/festructs/notifications.go index b0f5050..28ef4a1 100644 --- a/aether-core/aether/frontend/festructs/notifications.go +++ b/aether-core/aether/frontend/festructs/notifications.go @@ -54,7 +54,7 @@ func NewNotificationsBucket(now int64) NotificationsBucket { func (c *NotificationsContainer) Insert(ce CompiledPost, now int64) { // Check if post exists anywhere. We might have raised a notification for it already. - for k, _ := range c.NotificationsBuckets { + for k := range c.NotificationsBuckets { if c.NotificationsBuckets[k].ResponsePosts[ce.Fingerprint] != 0 { return } @@ -62,7 +62,7 @@ func (c *NotificationsContainer) Insert(ce CompiledPost, now int64) { // Go through all notifications buckets available that aren't already read. var latestNonReadNBLastUpdate int64 latestNonReadNBIndex := -1 - for k, _ := range c.NotificationsBuckets { + for k := range c.NotificationsBuckets { if c.NotificationsBuckets[k].Read { // If bucket is read, pass, we can't do anything to that any more. continue @@ -149,15 +149,15 @@ func (nc *NotificationsCarrier) MarkRead(fp string) { nc.lock.Lock() defer nc.lock.Unlock() container := nc.Containers[fp] - for k, _ := range container.NotificationsBuckets { + for k := range container.NotificationsBuckets { container.NotificationsBuckets[k].Read = true } nc.Containers[fp] = container } func (nc *NotificationsCarrier) markAllAsRead() { - for i, _ := range nc.Containers { - for j, _ := range nc.Containers[i].NotificationsBuckets { + for i := range nc.Containers { + for j := range nc.Containers[i].NotificationsBuckets { nc.Containers[i].NotificationsBuckets[j].Read = true } } @@ -173,7 +173,7 @@ func (nc *NotificationsCarrier) MarkAllAsRead() { func (nc *NotificationsCarrier) Prune() { cutoff := toolbox.CnvToCutoffDays(30) - for k, _ := range nc.Containers { + for k := range nc.Containers { if nc.Containers[k].LastUpdate < cutoff { delete(nc.Containers, k) } @@ -189,7 +189,7 @@ func (nc *NotificationsCarrier) InsertPosts(posts []CompiledPost) { var nonSelfPosts []CompiledPost now := time.Now().Unix() // If it's a self post, add to the map - for k, _ := range posts { + for k := range posts { if posts[k].SelfCreated { nContainer := nc.Containers[posts[k].Fingerprint] nContainer.Post = posts[k] @@ -201,7 +201,7 @@ func (nc *NotificationsCarrier) InsertPosts(posts []CompiledPost) { } // ^ Be mindful that we're removing self posts from the lists to be checked. That means responding to yourself will not raise a notification. Neat. // If not a self post, check if its parent matches a known self thread or post. - for k, _ := range nonSelfPosts { + for k := range nonSelfPosts { if nc.responseToSelfPost(&nonSelfPosts[k]) { logging.Logf(2, "This is a response to a self post! %v", nonSelfPosts[k].Fingerprint) // It's a response to a self post. Insert it. @@ -225,7 +225,7 @@ func (nc *NotificationsCarrier) InsertPosts(posts []CompiledPost) { func (nc *NotificationsCarrier) InsertThreads(threads []CompiledThread) { nc.lock.Lock() defer nc.lock.Unlock() - for k, _ := range threads { + for k := range threads { if !threads[k].SelfCreated { continue } @@ -364,7 +364,7 @@ func (nc *NotificationsCarrier) Listify() (CNotificationsList, int64) { cnl := CNotificationsList{} // For each container - for k, _ := range nc.Containers { + for k := range nc.Containers { // Skip if muted if nc.Containers[k].Muted { continue @@ -375,7 +375,7 @@ func (nc *NotificationsCarrier) Listify() (CNotificationsList, int64) { nType = REPLY_TO_THREAD } // For every bucket in container - for k2, _ := range nc.Containers[k].NotificationsBuckets { + for k2 := range nc.Containers[k].NotificationsBuckets { if len(nc.Containers[k].NotificationsBuckets[k2].ResponsePosts) == 0 { // Skip if no responses (generally impossible, but good to guard against) continue @@ -384,12 +384,12 @@ func (nc *NotificationsCarrier) Listify() (CNotificationsList, int64) { var rpFps []string rpUsers := nc.Containers[k].NotificationsBuckets[k2].ResponsePostsUsers - for k, _ := range nc.Containers[k].NotificationsBuckets[k2].ResponsePosts { + for k := range nc.Containers[k].NotificationsBuckets[k2].ResponsePosts { rpFps = append(rpFps, k) } // Figure out the newest response in the bucket and use its timestamp var newest int64 - for k3, _ := range nc.Containers[k].NotificationsBuckets[k2].ResponsePosts { + for k3 := range nc.Containers[k].NotificationsBuckets[k2].ResponsePosts { if nc.Containers[k].NotificationsBuckets[k2].ResponsePosts[k3] > newest { newest = nc.Containers[k].NotificationsBuckets[k2].ResponsePosts[k3] } diff --git a/aether-core/aether/frontend/festructs/protoconv.go b/aether-core/aether/frontend/festructs/protoconv.go index c528700..0976ec8 100644 --- a/aether-core/aether/frontend/festructs/protoconv.go +++ b/aether-core/aether/frontend/festructs/protoconv.go @@ -100,7 +100,7 @@ func ExplainedSignalSliceToProtobuf(exps []ExplainedSignal) []*pb.ExplainedSigna } var pbexps []*pb.ExplainedSignalEntity - for key, _ := range exps { + for key := range exps { pbexps = append(pbexps, exps[key].Protobuf()) } return pbexps @@ -156,7 +156,7 @@ func (e *AmbientBoard) Protobuf() *pb.AmbientBoardEntity { func (e *AmbientBoardBatch) Protobuf() []*pb.AmbientBoardEntity { var abes []*pb.AmbientBoardEntity - for key, _ := range e.Boards { + for key := range e.Boards { abes = append(abes, e.Boards[key].Protobuf()) } return abes @@ -194,7 +194,7 @@ func (e *CUserUsername) Protobuf() *pb.CUserUsername { func (e *CNotificationsList) Protobuf() []*pb.CompiledNotification { var cns []*pb.CompiledNotification - for key, _ := range *e { + for key := range *e { cns = append(cns, (*e)[key].Protobuf()) } return cns @@ -225,7 +225,7 @@ func (e *ModActionsTabEntry) Protobuf() *pb.ModActionsTabEntry { func (e *ReportsTabEntryBatch) Protobuf() []*pb.ReportsTabEntry { var eProtos []*pb.ReportsTabEntry - for k, _ := range *e { + for k := range *e { eProtos = append(eProtos, (*e)[k].Protobuf()) } return eProtos @@ -236,7 +236,7 @@ func (e *ReportsTabEntryBatch) Protobuf() []*pb.ReportsTabEntry { func (e *CBoardBatch) Protobuf() []*pb.CompiledBoardEntity { var eProtos []*pb.CompiledBoardEntity - for k, _ := range *e { + for k := range *e { eProtos = append(eProtos, (*e)[k].Protobuf()) } return eProtos @@ -245,7 +245,7 @@ func (e *CBoardBatch) Protobuf() []*pb.CompiledBoardEntity { func (e *CThreadBatch) Protobuf() []*pb.CompiledThreadEntity { var eProtos []*pb.CompiledThreadEntity - for k, _ := range *e { + for k := range *e { eProtos = append(eProtos, (*e)[k].Protobuf()) } return eProtos @@ -254,7 +254,7 @@ func (e *CThreadBatch) Protobuf() []*pb.CompiledThreadEntity { func (e *CPostBatch) Protobuf() []*pb.CompiledPostEntity { var eProtos []*pb.CompiledPostEntity - for k, _ := range *e { + for k := range *e { eProtos = append(eProtos, (*e)[k].Protobuf()) } return eProtos @@ -263,7 +263,7 @@ func (e *CPostBatch) Protobuf() []*pb.CompiledPostEntity { func (e *CUserBatch) Protobuf() []*pb.CompiledUserEntity { var eProtos []*pb.CompiledUserEntity - for k, _ := range *e { + for k := range *e { eProtos = append(eProtos, (*e)[k].Protobuf()) } return eProtos diff --git a/aether-core/aether/frontend/festructs/tssignalcompiler.go b/aether-core/aether/frontend/festructs/tssignalcompiler.go index 484ce45..2870dcf 100644 --- a/aether-core/aether/frontend/festructs/tssignalcompiler.go +++ b/aether-core/aether/frontend/festructs/tssignalcompiler.go @@ -41,7 +41,7 @@ func (c *CompiledPT) Insert(s PublicTrustSignal, nowts int64) { /* This used to have s.Expiry > nowts as a condition below. It's removed because it can cut off updates to an item that was not expired when it was updated, but expired in the time it took for it to arrive. It should still be ineffectual, but it should be ineffectual in the right state. We should probably prevent propagation of the expired truststates in the backend, though. */ - for k, _ := range c.PTs { + for k := range c.PTs { if c.PTs[k].Fingerprint == s.Fingerprint && s.LastRefreshed > c.PTs[k].LastRefreshed { c.PTs[k] = s @@ -72,7 +72,7 @@ func (c *CompiledCN) Insert(s CanonicalNameSignal, nowts int64) { return } // Check if already exists - for k, _ := range c.CNs { + for k := range c.CNs { if c.CNs[k].Fingerprint != s.Fingerprint { continue } @@ -112,7 +112,7 @@ func (c *CompiledF451) Insert(s F451Signal, nowts int64) { return } // Check if already exists - for k, _ := range c.F451s { + for k := range c.F451s { if c.F451s[k].Fingerprint != s.Fingerprint { continue } @@ -232,7 +232,7 @@ func (c *CompiledPE) Insert(s PublicElectSignal, nowts int64) { type CPTBatch []CompiledPT func (cbatch *CPTBatch) Insert(pts []PublicTrustSignal, nowts int64) { - for k, _ := range pts { + for k := range pts { // cpt := cbatch.FindOrCreate(pts[k].TargetFingerprint) var cpt *CompiledPT i := cbatch.Find(pts[k].TargetFingerprint) @@ -248,7 +248,7 @@ func (cbatch *CPTBatch) Insert(pts []PublicTrustSignal, nowts int64) { } func (cbatch *CPTBatch) Find(targetfp string) int { - for k, _ := range *cbatch { + for k := range *cbatch { if targetfp == (*cbatch)[k].TargetFingerprint { return k } @@ -267,7 +267,7 @@ func (cbatch *CPTBatch) FindObj(targetfp string) CompiledPT { type CCNBatch []CompiledCN func (cbatch *CCNBatch) Insert(cns []CanonicalNameSignal, nowts int64) { - for k, _ := range cns { + for k := range cns { // ccn := cbatch.FindOrCreate(cns[k].TargetFingerprint) var ccn *CompiledCN i := cbatch.Find(cns[k].TargetFingerprint) @@ -283,7 +283,7 @@ func (cbatch *CCNBatch) Insert(cns []CanonicalNameSignal, nowts int64) { } func (cbatch *CCNBatch) Find(targetfp string) int { - for k, _ := range *cbatch { + for k := range *cbatch { if targetfp == (*cbatch)[k].TargetFingerprint { return k } @@ -302,7 +302,7 @@ func (cbatch *CCNBatch) FindObj(targetfp string) CompiledCN { type CF451Batch []CompiledF451 func (cbatch *CF451Batch) Insert(f451s []F451Signal, nowts int64) { - for k, _ := range f451s { + for k := range f451s { // cf451 := cbatch.FindOrCreate(f451s[k].TargetFingerprint) var cf451 *CompiledF451 i := cbatch.Find(f451s[k].TargetFingerprint) @@ -318,7 +318,7 @@ func (cbatch *CF451Batch) Insert(f451s []F451Signal, nowts int64) { } func (cbatch *CF451Batch) Find(targetfp string) int { - for k, _ := range *cbatch { + for k := range *cbatch { if targetfp == (*cbatch)[k].TargetFingerprint { return k } @@ -337,7 +337,7 @@ func (cbatch *CF451Batch) FindObj(targetfp string) CompiledF451 { type CPEBatch []CompiledPE func (cbatch *CPEBatch) Insert(pes []PublicElectSignal, nowts int64) { - for k, _ := range pes { + for k := range pes { var cpe *CompiledPE i := cbatch.Find(pes[k].TargetFingerprint) if i == -1 { @@ -352,7 +352,7 @@ func (cbatch *CPEBatch) Insert(pes []PublicElectSignal, nowts int64) { } func (cbatch *CPEBatch) Find(targetfp string) int { - for k, _ := range *cbatch { + for k := range *cbatch { if targetfp == (*cbatch)[k].TargetFingerprint { return k } diff --git a/aether-core/aether/frontend/festructs/tssignalreader.go b/aether-core/aether/frontend/festructs/tssignalreader.go index d5057f2..f3f9cad 100644 --- a/aether-core/aether/frontend/festructs/tssignalreader.go +++ b/aether-core/aether/frontend/festructs/tssignalreader.go @@ -48,7 +48,7 @@ func GetPTs(targetfp, domainfp string, startts, nowts int64) []PublicTrustSignal rawSignals := getTsBasedSignal(targetfp, domainfp, startts, nowts, 1, -1) var sgns []PublicTrustSignal - for k, _ := range rawSignals { + for k := range rawSignals { sgns = append(sgns, PublicTrustSignal{ BaseTruststateSignal: BaseTruststateSignal{ BaseSignal: BaseSignal{ @@ -74,7 +74,7 @@ func GetCNs(targetfp, domainfp string, startts, nowts int64) []CanonicalNameSign rawSignals := getTsBasedSignal(targetfp, domainfp, startts, nowts, 2, -1) var sgns []CanonicalNameSignal - for k, _ := range rawSignals { + for k := range rawSignals { tsmeta, err := metaparse.ReadMeta("Truststate", rawSignals[k].GetMeta()) if err != nil { logging.Logf(2, "We failed to parse this Meta field. Raw Meta field: %v, Entity: %v Error: %v", targetfp, err) @@ -109,7 +109,7 @@ func GetF451s(targetfp, domainfp string, startts, nowts int64) []F451Signal { rawSignals := getTsBasedSignal(targetfp, domainfp, startts, nowts, 3, -1) var sgns []F451Signal - for k, _ := range rawSignals { + for k := range rawSignals { sgns = append(sgns, F451Signal{ BaseTruststateSignal: BaseTruststateSignal{ BaseSignal: BaseSignal{ @@ -135,7 +135,7 @@ func GetPEs(targetfp, domainfp string, startts, nowts int64) []PublicElectSignal rawSignals := getTsBasedSignal(targetfp, domainfp, startts, nowts, 4, -1) var sgns []PublicElectSignal - for k, _ := range rawSignals { + for k := range rawSignals { sgns = append(sgns, PublicElectSignal{ BaseTruststateSignal: BaseTruststateSignal{ BaseSignal: BaseSignal{ diff --git a/aether-core/aether/frontend/festructs/vsignalcompiler.go b/aether-core/aether/frontend/festructs/vsignalcompiler.go index 4746d4f..b82bd3f 100644 --- a/aether-core/aether/frontend/festructs/vsignalcompiler.go +++ b/aether-core/aether/frontend/festructs/vsignalcompiler.go @@ -6,6 +6,7 @@ package festructs import ( "aether-core/aether/services/globals" "aether-core/aether/services/logging" + "github.com/willf/bloom" ) @@ -152,7 +153,7 @@ func (c *CompiledFG) Insert(sg FollowsGuidelinesSignal) { return } // If it already exists in the list, overwrite existing - for k, _ := range c.FGs { + for k := range c.FGs { if c.FGs[k].Fingerprint != sg.Fingerprint { continue } @@ -203,7 +204,7 @@ func (c *CompiledMA) Insert(sg ModActionsSignal) { return } // If it already exists in the list, overwrite existing - for k, _ := range c.MAs { + for k := range c.MAs { if c.MAs[k].Fingerprint != sg.Fingerprint { continue } @@ -251,7 +252,7 @@ func (c *CompiledMA) Insert(sg ModActionsSignal) { type CATDBatch []CompiledATD func (cbatch *CATDBatch) Insert(atds []AddsToDiscussionSignal, nowts int64) { - for k, _ := range atds { + for k := range atds { // catd := cbatch.FindOrCreate(atds[k].TargetFingerprint) var catd *CompiledATD i := cbatch.Find(atds[k].TargetFingerprint) @@ -267,7 +268,7 @@ func (cbatch *CATDBatch) Insert(atds []AddsToDiscussionSignal, nowts int64) { } func (cbatch *CATDBatch) Find(targetfp string) int { - for k, _ := range *cbatch { + for k := range *cbatch { if targetfp == (*cbatch)[k].TargetFingerprint { return k } @@ -280,7 +281,7 @@ type CFGBatch []CompiledFG func (batch *CFGBatch) Insert(signals []FollowsGuidelinesSignal, nowts int64) { - for k, _ := range signals { + for k := range signals { var compiledSignal *CompiledFG i := batch.Find(signals[k].TargetFingerprint) if i == -1 { @@ -295,7 +296,7 @@ func (batch *CFGBatch) Insert(signals []FollowsGuidelinesSignal, nowts int64) { } func (batch *CFGBatch) Find(targetfp string) int { - for k, _ := range *batch { + for k := range *batch { if targetfp == (*batch)[k].TargetFingerprint { return k } @@ -307,7 +308,7 @@ func (batch *CFGBatch) Find(targetfp string) int { type CMABatch []CompiledMA func (batch *CMABatch) Insert(signals []ModActionsSignal, nowts int64) { - for k, _ := range signals { + for k := range signals { var compiledSignal *CompiledMA i := batch.Find(signals[k].TargetFingerprint) if i == -1 { @@ -322,7 +323,7 @@ func (batch *CMABatch) Insert(signals []ModActionsSignal, nowts int64) { } func (batch *CMABatch) Find(targetfp string) int { - for k, _ := range *batch { + for k := range *batch { if targetfp == (*batch)[k].TargetFingerprint { return k } diff --git a/aether-core/aether/frontend/festructs/vsignalreader.go b/aether-core/aether/frontend/festructs/vsignalreader.go index ee48f89..35069eb 100644 --- a/aether-core/aether/frontend/festructs/vsignalreader.go +++ b/aether-core/aether/frontend/festructs/vsignalreader.go @@ -49,7 +49,7 @@ func GetATDs(parentfp, parenttype, targetfp string, startts, nowts int64, noDesc rawSignals := getVoteBasedSignal(parentfp, parenttype, targetfp, startts, nowts, 1, -1, noDescendants) var sgns []AddsToDiscussionSignal - for k, _ := range rawSignals { + for k := range rawSignals { sgns = append(sgns, AddsToDiscussionSignal{ BaseVoteSignal: BaseVoteSignal{ Fingerprint: rawSignals[k].GetProvable().GetFingerprint(), @@ -71,7 +71,7 @@ func GetFGs(parentfp, parenttype, targetfp string, startts, nowts int64, noDesce rawSignals := getVoteBasedSignal(parentfp, parenttype, targetfp, startts, nowts, 2, -1, noDescendants) var sgns []FollowsGuidelinesSignal - for k, _ := range rawSignals { + for k := range rawSignals { vmeta, err := metaparse.ReadMeta("Vote", rawSignals[k].GetMeta()) if err != nil { logging.Logf(2, "We failed to parse this Meta field. Raw Meta field: %v, Entity: %v Error: %v", targetfp, err) @@ -102,7 +102,7 @@ func GetMAs(parentfp, parenttype, targetfp string, startts, nowts int64, noDesce rawSignals := getVoteBasedSignal(parentfp, parenttype, targetfp, startts, nowts, 3, -1, noDescendants) var sgns []ModActionsSignal - for k, _ := range rawSignals { + for k := range rawSignals { vmeta, err := metaparse.ReadMeta("Vote", rawSignals[k].GetMeta()) if err != nil { logging.Logf(2, "We failed to parse this Meta field. Raw Meta field: %v, Entity: %v Error: %v", targetfp, err) diff --git a/aether-core/aether/frontend/inflights/inflights.go b/aether-core/aether/frontend/inflights/inflights.go index d35279b..b3dc5e3 100644 --- a/aether-core/aether/frontend/inflights/inflights.go +++ b/aether-core/aether/frontend/inflights/inflights.go @@ -50,22 +50,22 @@ func (o *inflights) Protobuf() *clapi.Inflights { o.lock.Lock() defer o.lock.Unlock() opb := clapi.Inflights{} - for k, _ := range o.InflightBoards { + for k := range o.InflightBoards { opb.Boards = append(opb.Boards, o.InflightBoards[k].Protobuf()) } - for k, _ := range o.InflightThreads { + for k := range o.InflightThreads { opb.Threads = append(opb.Threads, o.InflightThreads[k].Protobuf()) } - for k, _ := range o.InflightPosts { + for k := range o.InflightPosts { opb.Posts = append(opb.Posts, o.InflightPosts[k].Protobuf()) } - for k, _ := range o.InflightVotes { + for k := range o.InflightVotes { opb.Votes = append(opb.Votes, o.InflightVotes[k].Protobuf()) } - for k, _ := range o.InflightKeys { + for k := range o.InflightKeys { opb.Keys = append(opb.Keys, o.InflightKeys[k].Protobuf()) } - for k, _ := range o.InflightTruststates { + for k := range o.InflightTruststates { opb.Truststates = append(opb.Truststates, o.InflightTruststates[k].Protobuf()) } return &opb @@ -186,7 +186,7 @@ func (o *InflightStatus) setCompletionPercent() { return } clp := 0 - for k, _ := range statusesOrdered { + for k := range statusesOrdered { if statusesOrdered[k] == o.StatusText { clp = (k * 100) / (len(statusesOrdered) - 1) // ^ If you have 6 items, k will be 0-5 range, if you don't do -1 it will never be 100%. @@ -412,7 +412,7 @@ func (o *inflights) cleanRepeatVotes() { // votes that hasn't started processing var inProgressVotes []InflightVote // votes that have - for k, _ := range o.InflightVotes { + for k := range o.InflightVotes { if o.InflightVotes[k].Status.StatusText == STATUS_WAITING { unprocessedVotes = append(unprocessedVotes, o.InflightVotes[k]) continue @@ -421,7 +421,7 @@ func (o *inflights) cleanRepeatVotes() { } // Create a map of the latest versions of those unprocessed votes signalsTargetsInWaiting := make(map[string]int64) //target:timestamp - for k, _ := range unprocessedVotes { + for k := range unprocessedVotes { if signalsTargetsInWaiting[unprocessedVotes[k].Entity.GetTarget()] <= unprocessedVotes[k].Status.RequestedTimestamp { // "<=" bc. if it's coming later, likely it happened later. signalsTargetsInWaiting[unprocessedVotes[k].Entity.GetTarget()] = unprocessedVotes[k].Status.RequestedTimestamp @@ -430,7 +430,7 @@ func (o *inflights) cleanRepeatVotes() { // If they're the latest versions, grab them from the unproc votes list. var dedupedVotes []InflightVote - for k, _ := range unprocessedVotes { + for k := range unprocessedVotes { /* unprocessedVotes[k] = scan through 0 1 2 3 4 5 .. unprocessedVotes[len(unprocessedVotes)-1-k] = scan thru .. 5 4 3 2 1 0 @@ -453,7 +453,7 @@ func (o *inflights) cleanRepeatTruststates() { // tses that hasn't started processing var inProgressTses []InflightTruststate // tses that have - for k, _ := range o.InflightTruststates { + for k := range o.InflightTruststates { if o.InflightTruststates[k].Status.StatusText == STATUS_WAITING { unprocessedTses = append(unprocessedTses, o.InflightTruststates[k]) continue @@ -462,7 +462,7 @@ func (o *inflights) cleanRepeatTruststates() { } // Create a map of the latest versions of those unprocessed tses signalsTargetsInWaiting := make(map[string]int64) //target:timestamp - for k, _ := range unprocessedTses { + for k := range unprocessedTses { if signalsTargetsInWaiting[unprocessedTses[k].Entity.GetTarget()] < unprocessedTses[k].Status.RequestedTimestamp { // "<=" bc. if it's coming later, likely it happened later. signalsTargetsInWaiting[unprocessedTses[k].Entity.GetTarget()] = unprocessedTses[k].Status.RequestedTimestamp @@ -471,7 +471,7 @@ func (o *inflights) cleanRepeatTruststates() { // If they're the latest versions, grab them from the unproc votes list. var dedupedTs []InflightTruststate - for k, _ := range unprocessedTses { + for k := range unprocessedTses { if unprocessedTses[len(unprocessedTses)-1-k].Status.RequestedTimestamp == signalsTargetsInWaiting[unprocessedTses[len(unprocessedTses)-1-k].Entity.GetTarget()] { dedupedTs = append(dedupedTs, unprocessedTses[len(unprocessedTses)-1-k]) // And clean out the map, so no other vote can enter through the same fp:ts pair. @@ -736,7 +736,7 @@ func (o *inflights) Prune() { var newInflightBoards []InflightBoard - for k, _ := range o.InflightBoards { + for k := range o.InflightBoards { if o.InflightBoards[k].Status.Fulfilled() { // o.FulfilledBoards = append(o.FulfilledBoards, o.InflightBoards[k]) continue @@ -747,7 +747,7 @@ func (o *inflights) Prune() { var newInflightThreads []InflightThread - for k, _ := range o.InflightThreads { + for k := range o.InflightThreads { if o.InflightThreads[k].Status.Fulfilled() { // o.FulfilledThreads = append(o.FulfilledThreads, o.InflightThreads[k]) continue @@ -758,7 +758,7 @@ func (o *inflights) Prune() { var newInflightPosts []InflightPost - for k, _ := range o.InflightPosts { + for k := range o.InflightPosts { if o.InflightPosts[k].Status.Fulfilled() { // o.FulfilledPosts = append(o.FulfilledPosts, o.InflightPosts[k]) continue @@ -769,7 +769,7 @@ func (o *inflights) Prune() { var newInflightVotes []InflightVote - for k, _ := range o.InflightVotes { + for k := range o.InflightVotes { if o.InflightVotes[k].Status.Fulfilled() { // o.FulfilledVotes = append(o.FulfilledVotes, o.InflightVotes[k]) continue @@ -780,7 +780,7 @@ func (o *inflights) Prune() { var newInflightKeys []InflightKey - for k, _ := range o.InflightKeys { + for k := range o.InflightKeys { if o.InflightKeys[k].Status.Fulfilled() { // o.FulfilledKeys = append(o.FulfilledKeys, o.InflightKeys[k]) continue @@ -791,7 +791,7 @@ func (o *inflights) Prune() { var newInflightTruststates []InflightTruststate - for k, _ := range o.InflightTruststates { + for k := range o.InflightTruststates { if o.InflightTruststates[k].Status.Fulfilled() { // o.FulfilledTruststates = append(o.FulfilledTruststates, o.InflightTruststates[k]) continue diff --git a/aether-core/aether/frontend/inflights/ingestor.go b/aether-core/aether/frontend/inflights/ingestor.go index 6902808..55960aa 100644 --- a/aether-core/aether/frontend/inflights/ingestor.go +++ b/aether-core/aether/frontend/inflights/ingestor.go @@ -117,32 +117,32 @@ func (o *inflights) getNextItem() interface{} { now := time.Now().Unix() var oldestEntity interface{} oldestTs := now - for k, _ := range o.InflightBoards { + for k := range o.InflightBoards { if e := o.InflightBoards[k]; e.Status.RequestedTimestamp <= oldestTs && (e.Status.StatusText == STATUS_WAITING || e.Status.StatusText == STATUS_MINTING) { oldestEntity = interface{}(&o.InflightBoards[k]) } } - for k, _ := range o.InflightThreads { + for k := range o.InflightThreads { if e := o.InflightThreads[k]; e.Status.RequestedTimestamp <= oldestTs && (e.Status.StatusText == STATUS_WAITING || e.Status.StatusText == STATUS_MINTING) { oldestEntity = interface{}(&o.InflightThreads[k]) } } - for k, _ := range o.InflightPosts { + for k := range o.InflightPosts { if e := o.InflightPosts[k]; e.Status.RequestedTimestamp <= oldestTs && (e.Status.StatusText == STATUS_WAITING || e.Status.StatusText == STATUS_MINTING) { oldestEntity = interface{}(&o.InflightPosts[k]) } } - for k, _ := range o.InflightVotes { + for k := range o.InflightVotes { if e := o.InflightVotes[k]; e.Status.RequestedTimestamp <= oldestTs && (e.Status.StatusText == STATUS_WAITING || e.Status.StatusText == STATUS_MINTING) { oldestEntity = interface{}(&o.InflightVotes[k]) } } - for k, _ := range o.InflightKeys { + for k := range o.InflightKeys { if e := o.InflightKeys[k]; e.Status.RequestedTimestamp <= oldestTs && (e.Status.StatusText == STATUS_WAITING || e.Status.StatusText == STATUS_MINTING) { oldestEntity = interface{}(&o.InflightKeys[k]) } } - for k, _ := range o.InflightTruststates { + for k := range o.InflightTruststates { if e := o.InflightTruststates[k]; e.Status.RequestedTimestamp <= oldestTs && (e.Status.StatusText == STATUS_WAITING || e.Status.StatusText == STATUS_MINTING) { oldestEntity = interface{}(&o.InflightTruststates[k]) } diff --git a/aether-core/aether/frontend/kvstore/find.go b/aether-core/aether/frontend/kvstore/find.go index 3bf2f50..46beb32 100644 --- a/aether-core/aether/frontend/kvstore/find.go +++ b/aether-core/aether/frontend/kvstore/find.go @@ -47,7 +47,7 @@ func findPost(sId Searchable) (festructs.CompiledPost, error) { func findPosts(searchResults search.SearchResults) []festructs.CompiledPost { var posts []festructs.CompiledPost - for k, _ := range searchResults.Results { + for k := range searchResults.Results { if searchResults.Results[k].Id.EntityType != "Post" { continue } @@ -84,7 +84,7 @@ func findThread(sId Searchable) (festructs.CompiledThread, error) { func findThreads(searchResults search.SearchResults) []festructs.CompiledThread { var threads []festructs.CompiledThread - for k, _ := range searchResults.Results { + for k := range searchResults.Results { if searchResults.Results[k].Id.EntityType != "Thread" { continue } @@ -122,7 +122,7 @@ func findBoard(searchResult search.SearchResult) (festructs.CompiledBoard, error func findBoards(searchResults search.SearchResults) []festructs.CompiledBoard { var boards []festructs.CompiledBoard - for k, _ := range searchResults.Results { + for k := range searchResults.Results { if searchResults.Results[k].Id.EntityType != "Board" { continue } @@ -162,7 +162,7 @@ func findUser(searchResult search.SearchResult) (festructs.CompiledUser, error) func findUsers(searchResults search.SearchResults) []festructs.CompiledUser { var users []festructs.CompiledUser - for k, _ := range searchResults.Results { + for k := range searchResults.Results { if searchResults.Results[k].Id.EntityType != "User" { continue } @@ -193,7 +193,7 @@ func findContent(searchResults search.SearchResults) ([]festructs.CompiledPost, var threads []festructs.CompiledThread - for k, _ := range searchResults.Results { + for k := range searchResults.Results { if searchResults.Results[k].Id.EntityType != "Post" && searchResults.Results[k].Id.EntityType != "Thread" { continue } @@ -228,7 +228,7 @@ func SearchContent(searchText string) (festructs.CPostBatch, festructs.CThreadBa func makeScoreMap(sr search.SearchResults) search.ScoreMap { sm := make(search.ScoreMap) - for k, _ := range sr.Results { + for k := range sr.Results { sm[sr.Results[k].Id.Fingerprint] = sr.Results[k].Score } return sm @@ -243,7 +243,7 @@ func GetNewFeedContent(newFeedItems []beapiconsumer.NewFeedItem) ([]festructs.Co var threads []festructs.CompiledThread - for k, _ := range newFeedItems { + for k := range newFeedItems { if newFeedItems[k].EntityType != "Post" && newFeedItems[k].EntityType != "Thread" && newFeedItems[k].EntityType != "Vote" { diff --git a/aether-core/aether/frontend/refresher/refresher.go b/aether-core/aether/frontend/refresher/refresher.go index 4214991..cffadf0 100644 --- a/aether-core/aether/frontend/refresher/refresher.go +++ b/aether-core/aether/frontend/refresher/refresher.go @@ -110,27 +110,27 @@ func DeleteStaleData(nowts int64) { var bcs []festructs.BoardCarrier query.Find(&bcs) - for i, _ := range bcs { - for j, _ := range bcs[i].Boards { + for i := range bcs { + for j := range bcs[i].Boards { bcs[i].Boards[j].DeleteFromSearchIndex() } } var tcs []festructs.ThreadCarrier query.Find(&tcs) - for i, _ := range tcs { - for j, _ := range tcs[i].Threads { + for i := range tcs { + for j := range tcs[i].Threads { bcs[i].Threads[j].DeleteFromSearchIndex() } - for j, _ := range tcs[i].Posts { + for j := range tcs[i].Posts { bcs[i].Posts[j].DeleteFromSearchIndex() } } var uhcs []festructs.UserHeaderCarrier query.Find(&uhcs) - for i, _ := range uhcs { - for j, _ := range uhcs[i].Users { + for i := range uhcs { + for j := range uhcs[i].Users { uhcs[i].Users[j].DeleteFromSearchIndex() } } @@ -165,7 +165,7 @@ func RefreshGlobalUserHeaders(newUserEntities []*pbstructs.Key, nowts int64, obs */ // toBeIndexed := festructs.CUserBatch{} uhcBatch := festructs.UHCBatch(uhcs) - for k, _ := range newUserEntities { + for k := range newUserEntities { if i := uhcBatch.Find(newUserEntities[k].GetProvable().GetFingerprint()); i != -1 { // It already exists uhcBatch[i].Users.InsertFromProtobuf([]*pbstructs.Key{newUserEntities[k]}, nowts) @@ -205,7 +205,7 @@ func RefreshBoards(nowts int64, extantABs *festructs.AmbientBoardBatch, observab bcBatch := festructs.BCBatch(bcs) bcBatch.Insert(newBoardEntities) wg := sync.WaitGroup{} - for k, _ := range bcBatch { + for k := range bcBatch { wg.Add(1) go RefreshBoard(bcBatch[k], &wg, extantABs, nowts) } @@ -236,7 +236,7 @@ func RefreshThreads(bc *festructs.BoardCarrier) { newThreadEntities := beapiconsumer.GetThreads(bc.LastReferenced, globals.FrontendTransientConfig.RefresherCacheNowTimestamp, []string{}, bc.Fingerprint, false, false) bc.Threads.InsertFromProtobuf(newThreadEntities) wg := sync.WaitGroup{} - for k, _ := range bc.Threads { + for k := range bc.Threads { wg.Add(1) go RefreshThread(bc.Threads[k], bc, &wg) } diff --git a/aether-core/aether/frontend/refresher/views.go b/aether-core/aether/frontend/refresher/views.go index 0afff1d..37cc267 100644 --- a/aether-core/aether/frontend/refresher/views.go +++ b/aether-core/aether/frontend/refresher/views.go @@ -33,7 +33,7 @@ func GenerateHomeView() { // Get the underlying compiled boards var subbedBoardFps []string - for k, _ := range sbs { + for k := range sbs { if !sbs[k].Notify { continue } @@ -41,11 +41,11 @@ func GenerateHomeView() { } boardCarriers := *getBoardsByFpList(subbedBoardFps) var thrs festructs.CThreadBatch - for k, _ := range boardCarriers { + for k := range boardCarriers { // thrlen := min(len(boardCarriers[k].Threads), 10) // boardThreads := boardCarriers[k].Threads[0:thrlen] boardThreads := *(boardCarriers[k].GetTopThreadsForView(10)) - for j, _ := range boardThreads { + for j := range boardThreads { boardThreads[j].ViewMeta_BoardName = boardCarriers[k].Boards[0].Name } thrs = append(thrs, boardThreads...) @@ -96,12 +96,12 @@ func GeneratePopularView() { logging.Logf(1, "base board carriers length: %v", len(boardCarriers)) logging.Logf(1, "sfwlist length: %v", len(globals.FrontendConfig.ContentRelations.SFWList.Boards)) var thrs festructs.CThreadBatch - for k, _ := range boardCarriers { + for k := range boardCarriers { // thrlen := min(len(boardCarriers[k].Threads), 10) // boardThreads := boardCarriers[k].Threads[0:thrlen] // thrs = append(thrs, boardThreads...) boardThreads := *(boardCarriers[k].GetTopThreadsForView(10)) - for j, _ := range boardThreads { + for j := range boardThreads { boardThreads[j].ViewMeta_BoardName = boardCarriers[k].Boards[0].Name } thrs = append(thrs, boardThreads...) @@ -204,7 +204,7 @@ func dedupePosts(posts []festructs.CompiledPost) festructs.CPostBatch { m := make(map[string]bool) var deduped []festructs.CompiledPost - for k, _ := range posts { + for k := range posts { if m[posts[k].Fingerprint] { // Already exists on the map - we have seen this before. continue @@ -220,7 +220,7 @@ func dedupeThreads(threads []festructs.CompiledThread) festructs.CThreadBatch { m := make(map[string]bool) var deduped []festructs.CompiledThread - for k, _ := range threads { + for k := range threads { if m[threads[k].Fingerprint] { // Already exists on the map - we have seen this before. logging.Logf(0, "This thread already exists, dedupe is removing it: %#v", threads[k]) diff --git a/aether-core/aether/frontend/search/search.go b/aether-core/aether/frontend/search/search.go index b4001ee..eecce5d 100644 --- a/aether-core/aether/frontend/search/search.go +++ b/aether-core/aether/frontend/search/search.go @@ -6,12 +6,15 @@ package search import ( "aether-core/aether/services/globals" "aether-core/aether/services/logging" + "github.com/blevesearch/bleve" + // bleveMapping "github.com/blevesearch/bleve/mapping" // "github.com/davecgh/go-spew/spew" - "github.com/json-iterator/go" "os" "path/filepath" + + "github.com/json-iterator/go" ) var ( @@ -151,7 +154,7 @@ func Search(searchText string) (SearchResults, error) { return SearchResults{}, err } srs := SearchResults{Query: searchText} - for k, _ := range results.Hits { + for k := range results.Hits { resultId := SearchId{} err := json.Unmarshal([]byte(results.Hits[k].ID), &resultId) if err != nil { diff --git a/aether-core/aether/io/api/apistructs.go b/aether-core/aether/io/api/apistructs.go index a7e6c99..a527111 100644 --- a/aether-core/aether/io/api/apistructs.go +++ b/aether-core/aether/io/api/apistructs.go @@ -486,22 +486,22 @@ type ApiResponse struct { func (r *ApiResponse) GetProvables() *[]Provable { var p []Provable - for key, _ := range r.ResponseBody.Boards { + for key := range r.ResponseBody.Boards { p = append(p, Provable(&r.ResponseBody.Boards[key])) } - for key, _ := range r.ResponseBody.Threads { + for key := range r.ResponseBody.Threads { p = append(p, Provable(&r.ResponseBody.Threads[key])) } - for key, _ := range r.ResponseBody.Posts { + for key := range r.ResponseBody.Posts { p = append(p, Provable(&r.ResponseBody.Posts[key])) } - for key, _ := range r.ResponseBody.Votes { + for key := range r.ResponseBody.Votes { p = append(p, Provable(&r.ResponseBody.Votes[key])) } - for key, _ := range r.ResponseBody.Keys { + for key := range r.ResponseBody.Keys { p = append(p, Provable(&r.ResponseBody.Keys[key])) } - for key, _ := range r.ResponseBody.Truststates { + for key := range r.ResponseBody.Truststates { p = append(p, Provable(&r.ResponseBody.Truststates[key])) } return &p @@ -551,7 +551,7 @@ func (r *ApiResponse) Verify() []error { return []error{fmt.Errorf("This ApiResponse's remote Address failed the boundary check. ApiResponse.Address: %#v", r.Address)} } // This is all the verification we need for addresses - just a bounds check. It does not go into the more involved Verify() flow. - for key, _ := range r.ResponseBody.Addresses { // this is a concrete type.. + for key := range r.ResponseBody.Addresses { // this is a concrete type.. err := Verify(&r.ResponseBody.Addresses[key]) if err != nil { errs = append(errs, err) @@ -936,37 +936,37 @@ func (r *Response) Insert(r2 *Response) { func (r *Response) IndexOf(item Provable) int { switch entity := item.(type) { case *Board: - for key, _ := range r.Boards { + for key := range r.Boards { if r.Boards[key].Fingerprint == entity.Fingerprint { return key } } case *Thread: - for key, _ := range r.Threads { + for key := range r.Threads { if r.Threads[key].Fingerprint == entity.Fingerprint { return key } } case *Post: - for key, _ := range r.Posts { + for key := range r.Posts { if r.Posts[key].Fingerprint == entity.Fingerprint { return key } } case *Vote: - for key, _ := range r.Votes { + for key := range r.Votes { if r.Votes[key].Fingerprint == entity.Fingerprint { return key } } case *Key: - for key, _ := range r.Keys { + for key := range r.Keys { if r.Keys[key].Fingerprint == entity.Fingerprint { return key } } case *Truststate: - for key, _ := range r.Truststates { + for key := range r.Truststates { if r.Truststates[key].Fingerprint == entity.Fingerprint { return key } @@ -1010,7 +1010,7 @@ func (r *Response) RemoveByIndex(i int, entityType string) { } func isInIndexSlice(idx int, idxs []int) bool { - for key, _ := range idxs { + for key := range idxs { if idx == idxs[key] { idxs = append(idxs[0:key], idxs[key+1:len(idxs)]...) return true @@ -1032,7 +1032,7 @@ func (r *Response) MassRemoveByIndex(idxs []int, entityType string) { } var retained []Board - for key, _ := range r.Boards { + for key := range r.Boards { if !isInIndexSlice(key, idxs) { retained = append(retained, r.Boards[key]) } @@ -1045,7 +1045,7 @@ func (r *Response) MassRemoveByIndex(idxs []int, entityType string) { } var retained []Thread - for key, _ := range r.Threads { + for key := range r.Threads { if !isInIndexSlice(key, idxs) { retained = append(retained, r.Threads[key]) } @@ -1058,7 +1058,7 @@ func (r *Response) MassRemoveByIndex(idxs []int, entityType string) { } var retained []Post - for key, _ := range r.Posts { + for key := range r.Posts { if !isInIndexSlice(key, idxs) { retained = append(retained, r.Posts[key]) } @@ -1071,7 +1071,7 @@ func (r *Response) MassRemoveByIndex(idxs []int, entityType string) { } var retained []Vote - for key, _ := range r.Votes { + for key := range r.Votes { if !isInIndexSlice(key, idxs) { retained = append(retained, r.Votes[key]) } @@ -1084,7 +1084,7 @@ func (r *Response) MassRemoveByIndex(idxs []int, entityType string) { } var retained []Key - for key, _ := range r.Keys { + for key := range r.Keys { if !isInIndexSlice(key, idxs) { retained = append(retained, r.Keys[key]) } @@ -1097,7 +1097,7 @@ func (r *Response) MassRemoveByIndex(idxs []int, entityType string) { } var retained []Truststate - for key, _ := range r.Truststates { + for key := range r.Truststates { if !isInIndexSlice(key, idxs) { retained = append(retained, r.Truststates[key]) } diff --git a/aether-core/aether/io/api/boundscheck.go b/aether-core/aether/io/api/boundscheck.go index 2fc0281..f913180 100644 --- a/aether-core/aether/io/api/boundscheck.go +++ b/aether-core/aether/io/api/boundscheck.go @@ -237,7 +237,7 @@ func fingerprintSliceBC(item *[]Fingerprint, minLen, maxLen int) bool { if !sliceValid { return false } - for key, _ := range *item { + for key := range *item { if !fingerprintBC((*item)[key]) { return false } @@ -256,7 +256,7 @@ func timestampSliceBC(item *[]Timestamp, minLen, maxLen int) bool { if !sliceValid { return false } - for key, _ := range *item { + for key := range *item { if !timestampBC((*item)[key]) { return false } @@ -324,7 +324,7 @@ func boardOwnerSliceBC(item *[]BoardOwner) bool { sliceValid := intBC(int64(len(*item)), MIN_BOARD_BOARDOWNERS_V1, MAX_BOARD_BOARDOWNERS_V1) boardOwnersValid := true if sliceValid { - for key, _ := range *item { + for key := range *item { if !boardOwnerBC(&(*item)[key]) { boardOwnersValid = false break @@ -347,7 +347,7 @@ func subprotocolSliceBC(item *[]Subprotocol) bool { sliceValid := intBC(int64(len(*item)), MIN_ADDRESS_PROTOCOL_SUBPROTOCOL_V1, MAX_ADDRESS_PROTOCOL_SUBPROTOCOL_V1) subprotocolsValid := true if sliceValid { - for key, _ := range *item { + for key := range *item { if !subprotocolBC(&(*item)[key]) { subprotocolsValid = false break @@ -419,7 +419,7 @@ func filterSliceBC(item *[]Filter, minLen, maxLen int) bool { if !sliceValid { return false } - for key, _ := range *item { + for key := range *item { if !filterBC(&(*item)[key]) { return false } @@ -446,7 +446,7 @@ func resultCacheSliceBC(item *[]ResultCache, minLen, maxLen int) bool { if !sliceValid { return false } - for key, _ := range *item { + for key := range *item { if !resultCacheBC(&(*item)[key]) { return false } @@ -464,7 +464,7 @@ func pageManifestEntitySliceBC(item *[]PageManifestEntity, minLen, maxLen int) b if !sliceValid { return false } - for key, _ := range *item { + for key := range *item { if !pageManifestEntityBC(&(*item)[key]) { return false } @@ -492,7 +492,7 @@ func pageManifestSliceBC(item *[]PageManifest, minLen, maxLen int) bool { if !sliceValid { return false } - for key, _ := range *item { + for key := range *item { if !pageManifestBC(&(*item)[key]) { return false } @@ -512,7 +512,7 @@ func entityCountSliceBC(item *[]EntityCount, minLen, maxLen int) bool { if !sliceValid { return false } - for key, _ := range *item { + for key := range *item { if !entityCountBC(&(*item)[key]) { return false } @@ -779,7 +779,7 @@ func (item *Address) CheckBounds() (bool, error) { } func checkIndexes(item *Answer) (bool, error) { - for key, _ := range item.BoardIndexes { + for key := range item.BoardIndexes { valid, err := item.BoardIndexes[key].CheckBounds() if err != nil { return false, fmt.Errorf("Check Index encountered a failure. Object: %#v", item.BoardIndexes[key]) @@ -788,7 +788,7 @@ func checkIndexes(item *Answer) (bool, error) { return false, nil } } - for key, _ := range item.ThreadIndexes { + for key := range item.ThreadIndexes { valid, err := item.ThreadIndexes[key].CheckBounds() if err != nil { return false, fmt.Errorf("Check Index encountered a failure. Object: %#v", item.ThreadIndexes[key]) @@ -797,7 +797,7 @@ func checkIndexes(item *Answer) (bool, error) { return false, nil } } - for key, _ := range item.PostIndexes { + for key := range item.PostIndexes { valid, err := item.PostIndexes[key].CheckBounds() if err != nil { return false, fmt.Errorf("Check Index encountered a failure. Object: %#v", item.PostIndexes[key]) @@ -806,7 +806,7 @@ func checkIndexes(item *Answer) (bool, error) { return false, nil } } - for key, _ := range item.VoteIndexes { + for key := range item.VoteIndexes { valid, err := item.VoteIndexes[key].CheckBounds() if err != nil { return false, fmt.Errorf("Check Index encountered a failure. Object: %#v", item.VoteIndexes[key]) @@ -815,7 +815,7 @@ func checkIndexes(item *Answer) (bool, error) { return false, nil } } - for key, _ := range item.KeyIndexes { + for key := range item.KeyIndexes { valid, err := item.KeyIndexes[key].CheckBounds() if err != nil { return false, fmt.Errorf("Check Index encountered a failure. Object: %#v", item.KeyIndexes[key]) @@ -824,7 +824,7 @@ func checkIndexes(item *Answer) (bool, error) { return false, nil } } - for key, _ := range item.TruststateIndexes { + for key := range item.TruststateIndexes { valid, err := item.TruststateIndexes[key].CheckBounds() if err != nil { return false, fmt.Errorf("Check Index encountered a failure. Object: %#v", item.TruststateIndexes[key]) @@ -833,7 +833,7 @@ func checkIndexes(item *Answer) (bool, error) { return false, nil } } - for key, _ := range item.AddressIndexes { + for key := range item.AddressIndexes { valid, err := item.AddressIndexes[key].CheckBounds() if err != nil { return false, fmt.Errorf("Check Index encountered a failure. Object: %#v", item.AddressIndexes[key]) diff --git a/aether-core/aether/io/api/fetcher.go b/aether-core/aether/io/api/fetcher.go index 1afb048..1fa7ad5 100644 --- a/aether-core/aether/io/api/fetcher.go +++ b/aether-core/aether/io/api/fetcher.go @@ -572,7 +572,7 @@ func generateHitlist(host string, subhost string, port uint16, location string, // Look at everything in the index and find the things that we want to pull. Page Number : bool pairs help us find which pages to hit. allPgs := make(map[int]bool) BoardLoop: - for key, _ := range manifestResponse.BoardManifests { + for key := range manifestResponse.BoardManifests { for _, val := range manifestResponse.BoardManifests[key].Entities { if !ExistsInDB("board", val.Fingerprint, val.LastUpdate) { // Grab the whole page and insert into to-be-fetched queue, DB will remove useless stuff. @@ -582,7 +582,7 @@ BoardLoop: } } ThreadLoop: - for key, _ := range manifestResponse.ThreadManifests { + for key := range manifestResponse.ThreadManifests { for _, val := range manifestResponse.ThreadManifests[key].Entities { if !ExistsInDB("thread", val.Fingerprint, val.LastUpdate) { // Grab the whole page and insert into to-be-fetched queue, DB will remove useless stuff. @@ -592,7 +592,7 @@ ThreadLoop: } } PostLoop: - for key, _ := range manifestResponse.PostManifests { + for key := range manifestResponse.PostManifests { for _, val := range manifestResponse.PostManifests[key].Entities { if !ExistsInDB("post", val.Fingerprint, val.LastUpdate) { // Grab the whole page and insert into to-be-fetched queue, DB will remove useless stuff. @@ -602,7 +602,7 @@ PostLoop: } } VoteLoop: - for key, _ := range manifestResponse.VoteManifests { + for key := range manifestResponse.VoteManifests { for _, val := range manifestResponse.VoteManifests[key].Entities { if !ExistsInDB("vote", val.Fingerprint, val.LastUpdate) { // Grab the whole page and insert into to-be-fetched queue, DB will remove useless stuff. @@ -612,7 +612,7 @@ VoteLoop: } } KeyLoop: - for key, _ := range manifestResponse.KeyManifests { + for key := range manifestResponse.KeyManifests { for _, val := range manifestResponse.KeyManifests[key].Entities { if !ExistsInDB("key", val.Fingerprint, val.LastUpdate) { // Grab the whole page and insert into to-be-fetched queue, DB will remove useless stuff. @@ -622,7 +622,7 @@ KeyLoop: } } TruststateLoop: - for key, _ := range manifestResponse.TruststateManifests { + for key := range manifestResponse.TruststateManifests { for _, val := range manifestResponse.TruststateManifests[key].Entities { if !ExistsInDB("truststate", val.Fingerprint, val.LastUpdate) { // Grab the whole page and insert into to-be-fetched queue, DB will remove useless stuff. @@ -735,7 +735,7 @@ func GetManifestGatedCache(host string, subhost string, port uint16, location st // For each page we have for this post response, hit the main cache and gather the data. mainResp := Response{} - for key, _ := range allPgs { + for key := range allPgs { loc := fmt.Sprint(location, "/", key, ".json") logging.Log(2, fmt.Sprintf("Making a request to %s\n", loc)) resp, _, err := GetPage(host, subhost, port, loc, "GET", []byte{}, reverseConn) diff --git a/aether-core/aether/io/api/protoconv.go b/aether-core/aether/io/api/protoconv.go index af7e4b5..0188a7a 100644 --- a/aether-core/aether/io/api/protoconv.go +++ b/aether-core/aether/io/api/protoconv.go @@ -58,7 +58,7 @@ func BOSliceToProtobuf(bos []BoardOwner) []*pb.BoardOwner { } var pbos []*pb.BoardOwner - for key, _ := range bos { + for key := range bos { pbos = append(pbos, bos[key].Protobuf()) } return pbos @@ -70,7 +70,7 @@ func FPSliceToProtobuf(fps []Fingerprint) []string { } var fpstr []string - for key, _ := range fps { + for key := range fps { fpstr = append(fpstr, string(fps[key])) } return fpstr @@ -244,7 +244,7 @@ func BoardOwnerSliceProtoToAPI(pbos []*pb.BoardOwner) []BoardOwner { } var abos []BoardOwner - for key, _ := range pbos { + for key := range pbos { bo := BoardOwner{} bo.FillFromProtobuf(*pbos[key]) abos = append(abos, bo) @@ -258,7 +258,7 @@ func FPSliceProtoToAPI(pfps []string) []Fingerprint { } var afps []Fingerprint - for key, _ := range pfps { + for key := range pfps { var fp Fingerprint fp.FillFromProtobuf(pfps[key]) afps = append(afps, fp) diff --git a/aether-core/aether/io/persistence/reader.go b/aether-core/aether/io/persistence/reader.go index b4365e8..137abb4 100644 --- a/aether-core/aether/io/persistence/reader.go +++ b/aether-core/aether/io/persistence/reader.go @@ -226,7 +226,7 @@ func Read( result.Boards = entities // Convert the result to []api.Provable - for i, _ := range entities { + for i := range entities { provableArr = append(provableArr, &entities[i]) } @@ -237,7 +237,7 @@ func Read( } result.Threads = entities // Convert the result to []api.Provable - for i, _ := range entities { + for i := range entities { provableArr = append(provableArr, &entities[i]) } case "posts": @@ -247,7 +247,7 @@ func Read( } result.Posts = entities // Convert the result to []api.Provable - for i, _ := range entities { + for i := range entities { provableArr = append(provableArr, &entities[i]) } @@ -258,7 +258,7 @@ func Read( } result.Votes = entities // Convert the result to []api.Provable - for i, _ := range entities { + for i := range entities { provableArr = append(provableArr, &entities[i]) } case "addresses": @@ -270,7 +270,7 @@ func Read( } result.Keys = entities // Convert the result to []api.Provable - for i, _ := range entities { + for i := range entities { provableArr = append(provableArr, &entities[i]) } case "truststates": @@ -280,7 +280,7 @@ func Read( } result.Truststates = entities // Convert the result to []api.Provable - for i, _ := range entities { + for i := range entities { provableArr = append(provableArr, &entities[i]) } } @@ -298,7 +298,7 @@ func Read( func existsInEmbed(asked string, embeds []string) bool { if len(embeds) > 0 { - for i, _ := range embeds { + for i := range embeds { if embeds[i] == asked { return true } @@ -316,7 +316,7 @@ func handleEmbeds(entities []api.Provable, result *api.Response, embeds []string return err } result.Threads = thr - for i, _ := range thr { + for i := range thr { firstEmbedCache = append(firstEmbedCache, &thr[i]) } @@ -328,7 +328,7 @@ func handleEmbeds(entities []api.Provable, result *api.Response, embeds []string return err } result.Posts = posts - for i, _ := range posts { + for i := range posts { firstEmbedCache = append(firstEmbedCache, &posts[i]) } } @@ -338,7 +338,7 @@ func handleEmbeds(entities []api.Provable, result *api.Response, embeds []string return err } result.Votes = votes - for i, _ := range votes { + for i := range votes { firstEmbedCache = append(firstEmbedCache, &votes[i]) } } @@ -374,7 +374,7 @@ func ReadThreadEmbed(entities []api.Provable) ([]api.Thread, error) { case *api.Board: // Only defined for boards. No other entity has thread embeds. entity = entity // Stop complaining - for i, _ := range entities { + for i := range entities { entityFingerprints = append(entityFingerprints, entities[i].GetFingerprint()) } query, args, err := sqlx.In("SELECT DISTINCT * FROM Threads WHERE Board IN (?);", entityFingerprints) @@ -423,7 +423,7 @@ func ReadPostEmbed(entities []api.Provable) ([]api.Post, error) { case *api.Thread: // Only defined for threads. No other entity has post embeds. entity = entity // Stop complaining - for i, _ := range entities { + for i := range entities { entityFingerprints = append(entityFingerprints, entities[i].GetFingerprint()) } query, args, err := sqlx.In("SELECT DISTINCT * FROM Posts WHERE Thread IN (?);", entityFingerprints) @@ -472,7 +472,7 @@ func ReadVoteEmbed(entities []api.Provable) ([]api.Vote, error) { case *api.Post: // Only defined for posts. No other entity has vote embeds. entity = entity // Stop complaining - for i, _ := range entities { + for i := range entities { entityFingerprints = append(entityFingerprints, entities[i].GetFingerprint()) } query, args, err := sqlx.In("SELECT DISTINCT * FROM Votes WHERE Target IN (?);", entityFingerprints) @@ -517,12 +517,12 @@ func ReadKeyEmbed(entities []api.Provable, firstEmbedCache []api.Provable) ([]ap return arr, nil } entities = append(entities, firstEmbedCache...) - for i, _ := range entities { + for i := range entities { switch entity := entities[i].(type) { // entity: typed API object. case *api.Board: entityOwners = append(entityOwners, entity.GetOwner()) - for j, _ := range entity.BoardOwners { + for j := range entity.BoardOwners { entityOwners = append(entityOwners, entity.BoardOwners[j].KeyFingerprint) } case *api.Thread, *api.Post, *api.Truststate: diff --git a/aether-core/aether/io/persistence/writer.go b/aether-core/aether/io/persistence/writer.go index 2492d5d..ae1263e 100644 --- a/aether-core/aether/io/persistence/writer.go +++ b/aether-core/aether/io/persistence/writer.go @@ -104,7 +104,7 @@ func AddrTrustedInsert(a *[]api.Address) error { if dbErr != nil { logging.LogCrash(dbErr) } - for key, _ := range *a { + for key := range *a { (*a)[key].SetVerified(true) aPkIface, err := APItoDB((*a)[key], time.Now()) if err != nil { @@ -159,7 +159,7 @@ func AddrTrustedInsert(a *[]api.Address) error { func InsertOrUpdateAddresses(a *[]api.Address) []error { var errs []error - for key, _ := range *a { + for key := range *a { (*a)[key].SetVerified(true) valid, err := (*a)[key].CheckBounds() if err != nil { diff --git a/aether-core/aether/services/ca/ca.go b/aether-core/aether/services/ca/ca.go index 7787ccb..e179104 100644 --- a/aether-core/aether/services/ca/ca.go +++ b/aether-core/aether/services/ca/ca.go @@ -3,8 +3,6 @@ package ca -import () - var ( trustedCAsPKs = []string{"142ae631bcd46ab6e548c9b2d9494c7e30c65b4389e541e31bbe31e0ae47515e"} trustedCAFps = []string{"5460a18d7dd4c6b078199f5ee8ee70037f877166b07e9596cf26deb73223e15c"} @@ -13,7 +11,7 @@ var ( // IsTrustedCAKeyByPK checks whether a key is one of our trusted CA keys based on the PK. Mind that this function does not actually check whether the message that this CA key came in is valid, so you should run this after you've otherwise validated the message and you know the message is signed properly by the key that you're checking. func IsTrustedCAKeyByPK(publicKey string) bool { // return true // TODO (debug) - for key, _ := range trustedCAsPKs { + for key := range trustedCAsPKs { if publicKey == trustedCAsPKs[key] { return true } @@ -23,7 +21,7 @@ func IsTrustedCAKeyByPK(publicKey string) bool { func IsTrustedCAKeyByPKWithPriority(publicKey string) (bool, int) { // return true // TODO (debug) - for key, _ := range trustedCAsPKs { + for key := range trustedCAsPKs { if publicKey == trustedCAsPKs[key] { return true, key } @@ -34,7 +32,7 @@ func IsTrustedCAKeyByPKWithPriority(publicKey string) (bool, int) { // IsTrustedCAKeyByFp checks whether a key is one of our trusted CA keys based on the Fingerprint. Mind that this function does not actually check whether the message that this CA key came in is valid, so you should run this after you've otherwise validated the message and you know the message is signed properly by the key that you're checking. func IsTrustedCAKeyByFp(publicKey string) bool { // return true // TODO (debug) - for key, _ := range trustedCAFps { + for key := range trustedCAFps { if publicKey == trustedCAFps[key] { return true } @@ -44,7 +42,7 @@ func IsTrustedCAKeyByFp(publicKey string) bool { func IsTrustedCAKeyByFpWithPriority(publicKey string) (bool, int) { // return true // TODO (debug) - for key, _ := range trustedCAFps { + for key := range trustedCAFps { if publicKey == trustedCAFps[key] { return true, key } diff --git a/aether-core/aether/services/configstore/bouncer.go b/aether-core/aether/services/configstore/bouncer.go index 92c0695..28fc2a4 100644 --- a/aether-core/aether/services/configstore/bouncer.go +++ b/aether-core/aether/services/configstore/bouncer.go @@ -111,21 +111,21 @@ func (n *ConnectionRecord) hasHistoryOutboundLease() bool { func (n *Bouncer) indexOf(direction string, loc, subloc string, port uint16, inboundRev, outboundRev bool) int { switch direction { case "inbound": - for key, _ := range n.Inbounds { + for key := range n.Inbounds { if n.Inbounds[key].equal(ConnectionRecord{Location: loc, Sublocation: subloc, Port: port, Inbound_ReverseConn: inboundRev, Outbound_ReverseConn: outboundRev}) { return key } } return -1 case "outbound": - for key, _ := range n.Outbounds { + for key := range n.Outbounds { if n.Outbounds[key].equal(ConnectionRecord{Location: loc, Sublocation: subloc, Port: port, Inbound_ReverseConn: inboundRev, Outbound_ReverseConn: outboundRev}) { return key } } return -1 case "ping": - for key, _ := range n.Pings { + for key := range n.Pings { if n.Pings[key].equal(ConnectionRecord{Location: loc, Sublocation: subloc, Port: port}) { return key } @@ -404,13 +404,13 @@ func (b *Bouncer) GetLastInboundSyncTimestamp(onlyReverseConn bool) int64 { b.flush() ts := Timestamp(0) if onlyReverseConn { - for key, _ := range b.Inbounds { + for key := range b.Inbounds { if b.Inbounds[key].Inbound_ReverseConn && b.Inbounds[key].LastAccess > ts { ts = b.Inbounds[key].LastAccess } } - for key, _ := range b.InboundHistory { + for key := range b.InboundHistory { if b.InboundHistory[key].Inbound_ReverseConn && b.InboundHistory[key].LastAccess > ts { ts = b.InboundHistory[key].LastAccess @@ -418,12 +418,12 @@ func (b *Bouncer) GetLastInboundSyncTimestamp(onlyReverseConn bool) int64 { } return int64(ts) } - for key, _ := range b.Inbounds { + for key := range b.Inbounds { if b.Inbounds[key].LastAccess > ts { ts = b.Inbounds[key].LastAccess } } - for key, _ := range b.InboundHistory { + for key := range b.InboundHistory { if b.InboundHistory[key].LastAccess > ts { ts = b.InboundHistory[key].LastAccess } @@ -437,13 +437,13 @@ func (b *Bouncer) GetLastOutboundSyncTimestamp(onlySuccessful bool) int64 { b.flush() ts := Timestamp(0) if onlySuccessful { - for key, _ := range b.Outbounds { + for key := range b.Outbounds { if b.Outbounds[key].Outbound_Successful && b.Outbounds[key].LastAccess > ts { ts = b.Outbounds[key].LastAccess } } - for key, _ := range b.OutboundHistory { + for key := range b.OutboundHistory { if b.OutboundHistory[key].Outbound_Successful && b.OutboundHistory[key].LastAccess > ts { ts = b.OutboundHistory[key].LastAccess @@ -451,12 +451,12 @@ func (b *Bouncer) GetLastOutboundSyncTimestamp(onlySuccessful bool) int64 { } return int64(ts) } - for key, _ := range b.Outbounds { + for key := range b.Outbounds { if b.Outbounds[key].LastAccess > ts { ts = b.Outbounds[key].LastAccess } } - for key, _ := range b.OutboundHistory { + for key := range b.OutboundHistory { if b.OutboundHistory[key].LastAccess > ts { ts = b.OutboundHistory[key].LastAccess } @@ -469,7 +469,7 @@ func (b *Bouncer) GetLastPingTimestamp(onlySuccessful bool) int64 { defer b.lock.Unlock() b.flush() ts := Timestamp(0) - for key, _ := range b.Pings { + for key := range b.Pings { if b.Pings[key].LastAccess > ts { ts = b.Pings[key].LastAccess } @@ -492,7 +492,7 @@ func (b *Bouncer) GetInboundsInLastXMinutes(min uint, onlySuccessful bool) []Con - If looking for all, just all of them as gated by time limit */ if onlySuccessful { - for key, _ := range b.Inbounds { + for key := range b.Inbounds { if b.Inbounds[key].LastAccess <= cutoff { // If not within the X minutes we want, pass without further processing continue @@ -508,7 +508,7 @@ func (b *Bouncer) GetInboundsInLastXMinutes(min uint, onlySuccessful bool) []Con } } // Same as above, repeated below over inbound history - for key, _ := range b.InboundHistory { + for key := range b.InboundHistory { if b.InboundHistory[key].LastAccess <= cutoff { // If not within the X minutes we want, pass without further processing continue @@ -526,12 +526,12 @@ func (b *Bouncer) GetInboundsInLastXMinutes(min uint, onlySuccessful bool) []Con return results } // Not only successful, but all - for key, _ := range b.Inbounds { + for key := range b.Inbounds { if b.Inbounds[key].LastAccess > cutoff { results = append(results, b.Inbounds[key]) } } - for key, _ := range b.InboundHistory { + for key := range b.InboundHistory { if b.InboundHistory[key].LastAccess > cutoff { results = append(results, b.InboundHistory[key]) } @@ -547,13 +547,13 @@ func (b *Bouncer) GetOutboundsInLastXMinutes(min uint, onlySuccessful bool) []Co var results []ConnectionRecord if onlySuccessful { - for key, _ := range b.Outbounds { + for key := range b.Outbounds { if b.Outbounds[key].Outbound_Successful && b.Outbounds[key].LastAccess > cutoff { results = append(results, b.Outbounds[key]) } } - for key, _ := range b.OutboundHistory { + for key := range b.OutboundHistory { if b.OutboundHistory[key].Outbound_Successful && b.OutboundHistory[key].LastAccess > cutoff { results = append(results, b.OutboundHistory[key]) @@ -561,12 +561,12 @@ func (b *Bouncer) GetOutboundsInLastXMinutes(min uint, onlySuccessful bool) []Co } return results } - for key, _ := range b.Outbounds { + for key := range b.Outbounds { if b.Outbounds[key].LastAccess > cutoff { results = append(results, b.Outbounds[key]) } } - for key, _ := range b.OutboundHistory { + for key := range b.OutboundHistory { if b.OutboundHistory[key].LastAccess > cutoff { results = append(results, b.OutboundHistory[key]) } diff --git a/aether-core/aether/services/configstore/fecontentrelations.go b/aether-core/aether/services/configstore/fecontentrelations.go index 099ad44..5df2eaf 100644 --- a/aether-core/aether/services/configstore/fecontentrelations.go +++ b/aether-core/aether/services/configstore/fecontentrelations.go @@ -64,7 +64,7 @@ func (c *ContentRelations) IsSubbedBoard(fp string) (isSubbed, notifyEnabled boo } func (c *ContentRelations) FindBoard(fp string) int { - for key, _ := range c.SubbedBoards { + for key := range c.SubbedBoards { if c.SubbedBoards[key].Fingerprint == fp { return key } @@ -73,7 +73,7 @@ func (c *ContentRelations) FindBoard(fp string) int { } func (c *ContentRelations) FindThread(fp string) int { - for key, _ := range c.SubbedThreads { + for key := range c.SubbedThreads { if c.SubbedThreads[key].Fingerprint == fp { return key } @@ -255,7 +255,7 @@ func (list *sfwlist) IsSFWListedBoard(fp string) (isSFWListed bool) { } func (list *sfwlist) FindBoardInSFWList(fp string) int { - for key, _ := range list.Boards { + for key := range list.Boards { if list.Boards[key] == fp { return key } diff --git a/aether-core/aether/services/configstore/feuserrelations.go b/aether-core/aether/services/configstore/feuserrelations.go index d02e2df..d70969b 100644 --- a/aether-core/aether/services/configstore/feuserrelations.go +++ b/aether-core/aether/services/configstore/feuserrelations.go @@ -77,7 +77,7 @@ func (u *UserRelations) UnModDisqualifyUser(fp, domain string) { type BatchUser []User func (b *BatchUser) Find(fp, domain string) int { - for k, _ := range *b { + for k := range *b { if (*b)[k].Fingerprint == fp && (*b)[k].Domain == domain { return k } diff --git a/aether-core/aether/services/configstore/responsetracker.go b/aether-core/aether/services/configstore/responsetracker.go index 32d2cc2..18a6233 100644 --- a/aether-core/aether/services/configstore/responsetracker.go +++ b/aether-core/aether/services/configstore/responsetracker.go @@ -67,7 +67,7 @@ func deleteFromDisk(url string) { // collectCounts assumes there is only one type of entity - this function is internal to this library, do not use is elsewhere as that assumption won't hold anywhere else. func collectCounts(pres []POSTResponseEntry) EntityCount { ec := EntityCount{} - for i, _ := range pres { + for i := range pres { if i == 0 { // [0] below because they will only have one. (Guaranteed in getLongestUniqueTimespan) ec.Name = pres[i].EntityCounts[0].Name @@ -96,7 +96,7 @@ func (e *POSTResponseEntry) eligible() bool { // Basic repo actions func (r *POSTResponseRepo) indexOf(url string) int { - for i, _ := range r.Responses { + for i := range r.Responses { if r.Responses[i].ResponseUrl == url { return i } @@ -141,7 +141,7 @@ func (r *POSTResponseRepo) flush(cutoff Timestamp) { func (r *POSTResponseRepo) getLongestUniqueTimespan(t Timestamp, entityName string) *POSTResponseEntry { index := -1 longestDuration := Timestamp(0) // This starts from 0, which means we do not allow for the chain to start after the given timestamp. It has to start before. - for i, _ := range r.Responses { + for i := range r.Responses { only1Ec := len(r.Responses[i].EntityCounts) == 1 entityNameMatches := r.Responses[i].EntityCounts[0].Name == entityName hasEnoughTime := r.Responses[i].eligible() diff --git a/aether-core/aether/services/nonces/nonces.go b/aether-core/aether/services/nonces/nonces.go index 523c208..3206c7b 100644 --- a/aether-core/aether/services/nonces/nonces.go +++ b/aether-core/aether/services/nonces/nonces.go @@ -96,9 +96,9 @@ func (rn *RemotesNonces) flush(cutoff int64) { } newRn := make(map[publicKey][]nonce) // Go through every pk, - for key, _ := range rn.NoncesMap { + for key := range rn.NoncesMap { // And every nonce, - for i, _ := range rn.NoncesMap[key] { + for i := range rn.NoncesMap[key] { // If the nonce creation is after cutoff (i.e. still within MACS) if rn.NoncesMap[key][i].afterCutoff(cutoff) { // add it to the new list. @@ -141,7 +141,7 @@ func (rn *RemotesNonces) IsValid(pk, nonceStr string, apiRespTimestamp int64) bo return false } // Check if the nonce exists. - for i, _ := range rn.NoncesMap[pkey] { + for i := range rn.NoncesMap[pkey] { if rn.NoncesMap[pkey][i].nStr == nonceStr { return false // We already have this nonce, this is a replay. } diff --git a/aether-core/aether/services/rollingbloom/rollingbloom.go b/aether-core/aether/services/rollingbloom/rollingbloom.go index 59fd02b..161acc7 100644 --- a/aether-core/aether/services/rollingbloom/rollingbloom.go +++ b/aether-core/aether/services/rollingbloom/rollingbloom.go @@ -87,7 +87,7 @@ func (r *RollingBloom) TestString(str string) bool { // Count is guaranteed to not double count anything, because when we add things, we check *all* constituent blooms, and if it is present in any, we don't add. func (r *RollingBloom) Count() int { var c int - for k, _ := range r.ConstituentBlooms { + for k := range r.ConstituentBlooms { c += r.ConstituentBlooms[k].Count } return c @@ -108,7 +108,7 @@ func NewRollingBloom(maxDurationDays, GranularityDays, maxSize uint) RollingBloo } func (r *RollingBloom) teststr(str string) bool { - for k, _ := range r.ConstituentBlooms { + for k := range r.ConstituentBlooms { if r.ConstituentBlooms[k].TestString(str) { return true } @@ -133,7 +133,7 @@ func (r *RollingBloom) maintain() { var cleanedCBlooms []constituentBloom var lastBloomEnd int64 - for k, _ := range r.ConstituentBlooms { + for k := range r.ConstituentBlooms { // Move to the new list only if the new bloom is still valid in duration if b := r.ConstituentBlooms[k]; b.EndTimestamp > now.Add(-24*time.Hour*time.Duration(int(r.MaxDurationDays))).Unix() { // This bloom is valid. @@ -159,7 +159,7 @@ func (r *RollingBloom) maintain() { func (r *RollingBloom) getCurrentConstituentBloom() *constituentBloom { now := time.Now().Unix() - for k, _ := range r.ConstituentBlooms { + for k := range r.ConstituentBlooms { if r.ConstituentBlooms[k].EndTimestamp > now { return &r.ConstituentBlooms[k] } diff --git a/aether-core/aether/services/toolbox/toolbox.go b/aether-core/aether/services/toolbox/toolbox.go index d16aec8..60816a8 100644 --- a/aether-core/aether/services/toolbox/toolbox.go +++ b/aether-core/aether/services/toolbox/toolbox.go @@ -121,7 +121,7 @@ func ResetPath(path string) { } func IndexOf(searchString string, stringSlice []string) int { - for key, _ := range stringSlice { + for key := range stringSlice { if stringSlice[key] == searchString { return key }