forked from TrueCloudLab/frostfs-node
Evgenii Stratonikov
c7a12ca3d8
No big deal, but it is called multiple times in sorting routine, this easily results in 20 allocations per group traversal. ``` goos: linux goarch: amd64 pkg: git.frostfs.info/TrueCloudLab/frostfs-node/pkg/network cpu: 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz │ old │ new │ │ sec/op │ sec/op vs base │ AddressTLSEnabled-8 184.6n ± 1% 103.3n ± 6% -44.04% (p=0.000 n=10) │ old │ new │ │ B/op │ B/op vs base │ AddressTLSEnabled-8 704.0 ± 0% 0.0 ± 0% -100.00% (p=0.000 n=10) │ old │ new │ │ allocs/op │ allocs/op vs base │ AddressTLSEnabled-8 1.000 ± 0% 0.000 ± 0% -100.00% (p=0.000 n=10) ``` Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
18 lines
414 B
Go
18 lines
414 B
Go
package network
|
|
|
|
import (
|
|
"github.com/multiformats/go-multiaddr"
|
|
)
|
|
|
|
const (
|
|
tlsProtocolName = "tls"
|
|
)
|
|
|
|
// tls var is used for (un)wrapping other multiaddrs around TLS multiaddr.
|
|
var tls, _ = multiaddr.NewMultiaddr("/" + tlsProtocolName)
|
|
|
|
// IsTLSEnabled searches for wrapped TLS protocol in multiaddr.
|
|
func (a Address) IsTLSEnabled() bool {
|
|
_, err := a.ma.ValueForProtocol(multiaddr.P_TLS)
|
|
return err == nil
|
|
}
|