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

namesys/routing.go imports dht package preventing dht.Quorum() from being used with a custom routing option #5957

Open
cpacia opened this issue Jan 30, 2019 · 1 comment
Labels
effort/hours Estimated to take one or several hours exp/intermediate Prior experience is likely helpful help wanted Seeking public contribution on this issue P3 Low: Not priority right now status/ready Ready to be worked

Comments

@cpacia
Copy link

cpacia commented Jan 30, 2019

If a user is using a custom routing option (like for example, we are using a modified DHT in openbazaar) and they pass in a DhtRecordCount to namesys.Resolve. The routing resolver will call dht.Quorum(int(options.DhtRecordCount)) however, the dht package imported by routing.go is the native dht package and not the one set by the user. The quorum function doesn't apply the option to the custom routing option.

func Quorum(n int) ropts.Option {
	return func(opts *ropts.Options) error {
		if opts.Other == nil {
			opts.Other = make(map[interface{}]interface{}, 1)
		}
		opts.Other[quorumOptionKey{}] = n
		return nil
	}
}

I think the issue using a struct defined inside the package for quorumOptionKey rather than, say, a string.

@Stebalien
Copy link
Member

We picked that so we wouldn't ever get any conflicts. Using a new empty struct is go's suggested way to handle context keys so we just copied the pattern here.

However, I see your point. I guess there isn't really an issue with using a key like "dht-record-count". Baring a new package (or putting this in go-libp2p-routing), I can't think of a better solution.

@momack2 momack2 added this to Inbox in ipfs/go-ipfs May 9, 2019
@Stebalien Stebalien added exp/intermediate Prior experience is likely helpful effort/hours Estimated to take one or several hours help wanted Seeking public contribution on this issue P3 Low: Not priority right now status/ready Ready to be worked labels May 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort/hours Estimated to take one or several hours exp/intermediate Prior experience is likely helpful help wanted Seeking public contribution on this issue P3 Low: Not priority right now status/ready Ready to be worked
Projects
No open projects
Development

No branches or pull requests

2 participants