Skip to content

Commit

Permalink
Merge pull request #45 from Frigyes06/deepsource-autofix-cab96843
Browse files Browse the repository at this point in the history
remove unnecessary blank identifier
  • Loading branch information
Frigyes06 authored Jul 25, 2023
2 parents cf3cbe2 + be2b5b7 commit 0ce6156
Show file tree
Hide file tree
Showing 54 changed files with 478 additions and 469 deletions.
36 changes: 18 additions & 18 deletions aether-core/aether/backend/beapiserver/srvmethods.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
}
Expand All @@ -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)
Expand All @@ -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)
}
Expand All @@ -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{
Expand All @@ -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)
}
Expand All @@ -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,
Expand All @@ -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)
}
Expand All @@ -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)
Expand All @@ -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)
}
Expand All @@ -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,
Expand All @@ -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)
}
Expand Down Expand Up @@ -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))
Expand All @@ -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))
Expand All @@ -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))
Expand All @@ -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))
Expand All @@ -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))
Expand All @@ -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))
Expand Down
10 changes: 5 additions & 5 deletions aether-core/aether/backend/dispatch/addrscan.go
Original file line number Diff line number Diff line change
Expand Up @@ -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])
}
Expand All @@ -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 {
Expand Down Expand Up @@ -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])
}
Expand All @@ -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 {
Expand Down
10 changes: 5 additions & 5 deletions aether-core/aether/backend/dispatch/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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])
}
Expand Down Expand Up @@ -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.
Expand All @@ -120,15 +120,15 @@ 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)
}
}
// 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)
Expand Down
4 changes: 2 additions & 2 deletions aether-core/aether/backend/dispatch/dispatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion aether-core/aether/backend/dispatch/exclusions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
6 changes: 3 additions & 3 deletions aether-core/aether/backend/dispatch/explore.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.)
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down
7 changes: 4 additions & 3 deletions aether-core/aether/backend/dispatch/ping.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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{}
Expand All @@ -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
Expand All @@ -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])
Expand Down
Loading

0 comments on commit 0ce6156

Please sign in to comment.