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

Fix Bootstrap sub-queries #264

Merged
merged 2 commits into from
Feb 19, 2019
Merged
Show file tree
Hide file tree
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
10 changes: 7 additions & 3 deletions dht_bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,14 @@ func (dht *IpfsDHT) runBootstrap(ctx context.Context, cfg BootstrapConfig) error
defer logger.EventBegin(ctx, "dhtRunBootstrap").Done()

doQuery := func(n int, target string, f func(context.Context) error) error {
logger.Debugf("Bootstrapping query (%d/%d) to %s", n, cfg.Queries, target)
ctx, cancel := context.WithTimeout(ctx, cfg.Timeout)
logger.Infof("Bootstrapping query (%d/%d) to %s", n, cfg.Queries, target)
queryCtx, cancel := context.WithTimeout(ctx, cfg.Timeout)
defer cancel()
return f(ctx)
err := f(queryCtx)
if err == context.DeadlineExceeded && queryCtx.Err() == context.DeadlineExceeded && ctx.Err() == nil {
return nil
}
return err
}

// Do all but one of the bootstrap queries as random walks.
Expand Down
2 changes: 1 addition & 1 deletion query.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func (r *dhtQueryRunner) Run(ctx context.Context, peers []peer.ID) (*dhtQueryRes
case <-r.proc.Closed():
r.RLock()
defer r.RUnlock()
err = context.DeadlineExceeded
err = r.runCtx.Err()
}

if r.result != nil && r.result.success {
Expand Down