ipfs / ipfs/kubo

TopicDiscovery Used outside the project

Open
#9,435 0 comments 0 reactions 0 assignees View on GitHub
kind/feature
Dominant language
Go
Stars
17.1k
Forks
3.2k
Avg merge
3d 18h
Merged PRs (30d)
11

Description

### Checklist

- [X] My issue is specific & actionable.
- [X] I am not suggesting a protocol enhancement.
- [X] I have searched on the [issue tracker](https://github.com/ipfs/kubo/issues?q=is%3Aissue) for my issue.

### Description

我目前通过修改源代码的方式使用这个对象,还有更好的方式吗
I currently use this object by modifying the source code,Is there a better way

```

var TopicDisc discovery.Discovery

func TopicDiscovery() interface{} {
return func(host host.Host, cr routing.ContentRouting) (service discovery.Discovery, err error) {
baseDisc := disc.NewRoutingDiscovery(cr)
minBackoff, maxBackoff := time.Second*60, time.Hour
rng := rand.New(rand.NewSource(rand.Int63()))
d, err := backoff.NewBackoffDiscovery(
baseDisc,
backoff.NewExponentialBackoff(minBackoff, maxBackoff, backoff.FullJitter, time.Second, 5.0, 0, rng),
)

if err != nil {
return nil, err
}
TopicDisc = d
return d, nil
}
}

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.