-
-
Notifications
You must be signed in to change notification settings - Fork 50
discv5: only store crawl error if no query succeeded #55
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -13,7 +13,7 @@ import ( | |||||||||||||||
| "github.com/ethereum/go-ethereum/p2p/enode" | ||||||||||||||||
| "github.com/libp2p/go-libp2p/core/network" | ||||||||||||||||
| "github.com/libp2p/go-libp2p/core/peer" | ||||||||||||||||
| "github.com/libp2p/go-libp2p/p2p/host/basic" | ||||||||||||||||
| basichost "github.com/libp2p/go-libp2p/p2p/host/basic" | ||||||||||||||||
| ma "github.com/multiformats/go-multiaddr" | ||||||||||||||||
| log "github.com/sirupsen/logrus" | ||||||||||||||||
| "go.uber.org/atomic" | ||||||||||||||||
|
|
@@ -25,6 +25,8 @@ import ( | |||||||||||||||
| "github.com/dennis-tra/nebula-crawler/discvx" | ||||||||||||||||
| ) | ||||||||||||||||
|
|
||||||||||||||||
| const MAX_CRAWL_RETRY_AFTER_TIMEOUT = 2 // magic | ||||||||||||||||
|
|
||||||||||||||||
| type CrawlerConfig struct { | ||||||||||||||||
| DialTimeout time.Duration | ||||||||||||||||
| AddrDialType config.AddrType | ||||||||||||||||
|
|
@@ -460,18 +462,19 @@ func (c *Crawler) crawlDiscV5(ctx context.Context, pi PeerInfo) chan DiscV5Resul | |||||||||||||||
| result.RespondedAt = &now | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| success := false | ||||||||||||||||
| // loop through the buckets sequentially because discv5 is also doing that | ||||||||||||||||
| // internally, so we won't gain much by spawning multiple parallel go | ||||||||||||||||
| // routines here. Stop the process as soon as we have received a timeout and | ||||||||||||||||
| // don't let the following calls time out as well. | ||||||||||||||||
| for i := 0; i <= discvx.NBuckets; i++ { // 15 is maximum | ||||||||||||||||
| for i := 0; i <= discvx.NBuckets; i++ { // 17 is maximum | ||||||||||||||||
| var neighbors []*enode.Node | ||||||||||||||||
| neighbors, err = c.listener.FindNode(pi.Node, []uint{uint(discvx.HashBits - i)}) | ||||||||||||||||
| if err != nil { | ||||||||||||||||
|
|
||||||||||||||||
| if errors.Is(err, discvx.ErrTimeout) { | ||||||||||||||||
| timeouts += 1 | ||||||||||||||||
| if timeouts < 2 { | ||||||||||||||||
| if timeouts < MAX_CRAWL_RETRY_AFTER_TIMEOUT { | ||||||||||||||||
| continue | ||||||||||||||||
| } | ||||||||||||||||
| } | ||||||||||||||||
|
|
@@ -480,6 +483,8 @@ func (c *Crawler) crawlDiscV5(ctx context.Context, pi PeerInfo) chan DiscV5Resul | |||||||||||||||
| err = fmt.Errorf("getting closest peer with CPL %d: %w", i, err) | ||||||||||||||||
| break | ||||||||||||||||
| } | ||||||||||||||||
| success = true | ||||||||||||||||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. actually, could you use the However,
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updated: Lines 516 to 521 in 9a1a685
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ah sorry, I meant
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Line 481 in 9a1a685
You mean, if we exit the loop early we need to set the error bits to 1 for the buckets that were skipped? I'll update the
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lol, I was ctrl+f searching the page for
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||||||||||||
| timeouts = 0 | ||||||||||||||||
|
|
||||||||||||||||
| if result.RespondedAt == nil { | ||||||||||||||||
| now := time.Now() | ||||||||||||||||
|
|
@@ -510,6 +515,11 @@ func (c *Crawler) crawlDiscV5(ctx context.Context, pi PeerInfo) chan DiscV5Resul | |||||||||||||||
| result.RoutingTable.Neighbors = append(result.RoutingTable.Neighbors, n) | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| // if we have at least a successful result, delete error | ||||||||||||||||
| if success && result.Error != nil { | ||||||||||||||||
| result.Error = nil | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| // if there was a connection error, parse it to a known one | ||||||||||||||||
| if result.Error != nil { | ||||||||||||||||
| result.ErrorStr = db.NetError(result.Error) | ||||||||||||||||
|
|
||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.