10 Commits

Author SHA1 Message Date
Hector Sanjuan
0aa80854ab Let Multiaddr implement marshalers: binary, text, json 2019-02-25 22:48:24 +00:00
Steven Allen
58bcbc8e51 add component/foreach helpers
This adds a `Component` helper type and a `ForEach` helper method.

The first attempt used an interface but interfaces imply allocation. We really
can't afford to allocate here.
2018-10-01 21:18:11 -07:00
Steven Allen
61e31ed48b stop copying when calling Bytes
This is a huge performance hit. Really, we just need to tell users not to modify
the result.

Also, get rid of an unnecessary pointer indirection (no api change).
2018-10-01 16:56:57 -07:00
Richard Littauer
123bf94ac9 Changed jbenet to multiformats 2016-10-20 20:48:40 -04:00
Lars Gierth
e20e4e73a9 Update multiformats imports 2016-09-29 14:52:32 +02:00
Jeromy
a581da3f8f add method to lookup values in a multiaddr 2016-01-17 05:14:38 -08:00
Juan Batiz-Benet
17f4666d01 Protocols now value 2015-01-09 05:37:39 -08:00
Juan Batiz-Benet
9d04132166 Split + Join 2014-11-05 02:20:27 -08:00
Juan Batiz-Benet
4a5dcd3a4d Split: added split method 2014-11-04 23:20:17 -08:00
Juan Batiz-Benet
c90ef4472f New Multiaddr interface
This commit changes the struct to a new Multiaddr interface:

```Go
type Multiaddr interface {
  Equal(Multiaddr) bool
  Bytes() []byte
  String() string
  Protocols() []*Protocol
  Encapsulate(Multiaddr) Multiaddr
  Decapsulate(Multiaddr) Multiaddr
}
```

This means a few things have changed:

- use Multiaddr interface, struct not exported
- Bytes returns a copy of the internal bytes
- Some methods no longer return errors (catch errors in NewMultiaddr)
  - String (panics if malformed)
  - Protocols (panics if malformed)
  - Decapsulate (no-op if not prefix)
- Moved net-specific functions to package
  - Multiaddr.DialArgs() -> DialArgs(Multiaddr)
  - Multiaddr.IsThinWaist() -> IsThinWaist(Multiaddr)

cc @whyrusleeping @perfmode
2014-10-06 03:27:29 -07:00