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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 @@ -246,8 +246,8 @@ func (dht *FullRT) runCrawler(ctx context.Context) {
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{}

initialTrigger := make(chan struct{}, 1)
initialTrigger <- struct{}{}
Expand All @@ -263,15 +263,15 @@ func (dht *FullRT) runCrawler(ctx context.Context) {

var addrs []*peer.AddrInfo
dht.peerAddrsLk.Lock()
for k := range m {
for k := range foundPeers {
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)
}

start := time.Now()
Expand All @@ -295,9 +295,9 @@ func (dht *FullRT) runCrawler(ctx context.Context) {
return
}

mxLk.Lock()
defer mxLk.Unlock()
m[p] = &crawlVal{
foundPeersLk.Lock()
defer foundPeersLk.Unlock()
foundPeers[p] = &crawlVal{
addrs: addrs,
}
},
Expand All @@ -321,11 +321,11 @@ func (dht *FullRT) runCrawler(ctx context.Context) {
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)
}

dht.peerAddrsLk.Lock()
Expand Down