Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
dennis-tra committed Oct 23, 2024
1 parent ef3206d commit a18cb9e
Showing 1 changed file with 0 additions and 46 deletions.
46 changes: 0 additions & 46 deletions discv4/crawler.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"math/rand"
"net/netip"
"strings"
"sync"
"time"

mapset "github.com/deckarep/golang-set/v2"
Expand Down Expand Up @@ -338,51 +337,6 @@ func determineStrategy(sets []mapset.Set[string]) CrawlStrategy {
}
}

func (c *Crawler) crawlRemainingBucketsConcurrently(node *enode.Node, udpAddr netip.AddrPort, probesPerBucket int) map[string]PeerInfo {
var wg sync.WaitGroup

allNeighborsMu := sync.Mutex{}
allNeighbors := map[string]PeerInfo{}
for i := 1; i < 15; i++ { // although there are 17 buckets, GenRandomPublicKey only supports the first 16
for j := 0; j < probesPerBucket; j++ {
wg.Add(1)

go func() {
defer wg.Done()

// first, we generate a random key that falls into bucket 0
targetKey, err := GenRandomPublicKey(node.ID(), i)
if err != nil {
log.WithError(err).WithField("nodeID", node.ID().String()).Warnf("Failed generating random key for bucket %d", i)
return
}

// second, we do the Find node request
closest, err := c.listener.FindNode(node.ID(), udpAddr, targetKey)
if err != nil {
return
}

// third, update our neighbors map
allNeighborsMu.Lock()
defer allNeighborsMu.Unlock()

for _, c := range closest {
pi, err := NewPeerInfo(c)
if err != nil {
log.WithError(err).Warnln("Failed parsing ethereum node neighbor")
continue
}
allNeighbors[pi.DeduplicationKey()] = pi
}
}()
}
}
wg.Wait()

return allNeighbors
}

func (c *Crawler) crawlRemainingBucketsSequentially(node *enode.Node, udpAddr netip.AddrPort, probesPerBucket int) map[string]PeerInfo {
timeouts := 0
allNeighbors := map[string]PeerInfo{}
Expand Down

0 comments on commit a18cb9e

Please sign in to comment.