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 prioritization of stream muxers #8750

Merged
merged 2 commits into from
Feb 28, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions core/node/libp2p/libp2p.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ type priorityOption struct {

func prioritizeOptions(opts []priorityOption) libp2p.Option {
type popt struct {
priority int64
priority int64 // lower priority values mean higher priority
opt libp2p.Option
}
enabledOptions := make([]popt, 0, len(opts))
Expand All @@ -71,7 +71,7 @@ func prioritizeOptions(opts []priorityOption) libp2p.Option {
}
}
sort.Slice(enabledOptions, func(i, j int) bool {
return enabledOptions[i].priority > enabledOptions[j].priority
return enabledOptions[i].priority < enabledOptions[j].priority
})
p2pOpts := make([]libp2p.Option, len(enabledOptions))
for i, opt := range enabledOptions {
Expand Down
4 changes: 2 additions & 2 deletions core/node/libp2p/sec.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ func Security(enabled bool, tptConfig config.Transports) interface{} {
return func() (opts Libp2pOpts) {
opts.Opts = append(opts.Opts, prioritizeOptions([]priorityOption{{
priority: tptConfig.Security.TLS,
defaultPriority: 100,
defaultPriority: 200,
opt: libp2p.Security(tls.ID, tls.New),
}, {
priority: tptConfig.Security.Noise,
defaultPriority: 300,
defaultPriority: 100,
opt: libp2p.Security(noise.ID, noise.New),
}}))
return opts
Expand Down