mirror of
https://github.com/logos-messaging/go-multiaddr.git
synced 2026-01-02 13:03:11 +00:00
make cast use NewMultiaddrBytes
This will perform all the correct checks *except* that it won't bother actually stringifying the multiaddr. It should be significantly faster.
This commit is contained in:
parent
6c70a3d7b5
commit
2e9c819c18
4
util.go
4
util.go
@ -44,11 +44,11 @@ func Join(ms ...Multiaddr) Multiaddr {
|
||||
|
||||
// Cast re-casts a byte slice as a multiaddr. will panic if it fails to parse.
|
||||
func Cast(b []byte) Multiaddr {
|
||||
_, err := bytesToString(b)
|
||||
m, err := NewMultiaddrBytes(b)
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("multiaddr failed to parse: %s", err))
|
||||
}
|
||||
return multiaddr{bytes: b}
|
||||
return m
|
||||
}
|
||||
|
||||
// StringCast like Cast, but parses a string. Will also panic if it fails to parse.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user