Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance variable names on fullrt/dht.go #787

Merged
merged 2 commits into from
Feb 5, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions fullrt/dht.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,8 @@
defer dht.wg.Done()
t := time.NewTicker(dht.crawlerInterval)

m := make(map[peer.ID]*crawlVal)
mxLk := sync.Mutex{}
foundPeers := make(map[peer.ID]*crawlVal)
foundPeersLk := sync.Mutex{}

Check warning on line 298 in fullrt/dht.go

View check run for this annotation

Codecov / codecov/patch

fullrt/dht.go#L297-L298

Added lines #L297 - L298 were not covered by tests

initialTrigger := make(chan struct{}, 1)
initialTrigger <- struct{}{}
Expand All @@ -311,15 +311,15 @@

var addrs []*peer.AddrInfo
dht.peerAddrsLk.Lock()
for k := range m {
for k := range foundPeers {

Check warning on line 314 in fullrt/dht.go

View check run for this annotation

Codecov / codecov/patch

fullrt/dht.go#L314

Added line #L314 was not covered by tests
addrs = append(addrs, &peer.AddrInfo{ID: k}) // Addrs: v.addrs
}

addrs = append(addrs, dht.bootstrapPeers...)
dht.peerAddrsLk.Unlock()

for k := range m {
delete(m, k)
for k := range foundPeers {
delete(foundPeers, k)

Check warning on line 322 in fullrt/dht.go

View check run for this annotation

Codecov / codecov/patch

fullrt/dht.go#L321-L322

Added lines #L321 - L322 were not covered by tests
}

start := time.Now()
Expand All @@ -343,9 +343,9 @@
return
}

mxLk.Lock()
defer mxLk.Unlock()
m[p] = &crawlVal{
foundPeersLk.Lock()
defer foundPeersLk.Unlock()
foundPeers[p] = &crawlVal{

Check warning on line 348 in fullrt/dht.go

View check run for this annotation

Codecov / codecov/patch

fullrt/dht.go#L346-L348

Added lines #L346 - L348 were not covered by tests
addrs: addrs,
}
},
Expand All @@ -369,11 +369,11 @@
peerAddrs := make(map[peer.ID][]multiaddr.Multiaddr)
kPeerMap := make(map[string]peer.ID)
newRt := trie.New()
for k, v := range m {
v.key = kadkey.KbucketIDToKey(kb.ConvertPeerID(k))
peerAddrs[k] = v.addrs
kPeerMap[string(v.key)] = k
newRt.Add(v.key)
for peerID, foundCrawlVal := range foundPeers {
foundCrawlVal.key = kadkey.KbucketIDToKey(kb.ConvertPeerID(peerID))
peerAddrs[peerID] = foundCrawlVal.addrs
kPeerMap[string(foundCrawlVal.key)] = peerID
newRt.Add(foundCrawlVal.key)

Check warning on line 376 in fullrt/dht.go

View check run for this annotation

Codecov / codecov/patch

fullrt/dht.go#L372-L376

Added lines #L372 - L376 were not covered by tests
}

dht.peerAddrsLk.Lock()
Expand Down