Commit Graph

20 Commits

Author SHA1 Message Date
Steven Allen e3951368fb forbid empty multiaddrs
fixes #104
2019-05-20 12:23:28 -07:00
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
Steven Allen 5416c663d5 simplify variable-length argument handling
Instead of having the transformers deal with variable length argument prefixes,
just do this in the bytesToString/stringToBytes functions.
2018-06-22 13:29:31 -07:00
Steven Allen d814073552 remove debugging code
no point in slowing things down unnecessarily just for some debugging code.
2017-09-20 18:19:29 -07:00
Steven Allen 6362ccb0d2 preallocate protocol slice
This was showing up on CPU profiles as a significant source of repeated
allocations. We don't really care about over allocation (don't keep these slices
around) and should rarely have more than 8 protocols in a single address.
2017-09-20 18:17:12 -07:00
jbenet bdf3e3a444 added unix path protocol 2016-09-19 11:06:27 +08:00
Jeromy ad12fa30fe respond to CR feedback 2016-05-04 13:26:50 -07:00
Jeromy 9c4a0baf6d cleanup panics and make NewFromBytes faster 2016-04-29 14:16:41 -07:00
Jeromy ae64eb994b rewrite value for protocols and add more tests 2016-01-18 00:35:47 -08:00
Jeromy a581da3f8f add method to lookup values in a multiaddr 2016-01-17 05:14:38 -08:00
Juan Batiz-Benet c13f11bbfe varint-prefixed mvariable sized addrs 2015-01-20 14:16:49 -08:00
Juan Batiz-Benet 17f4666d01 Protocols now value 2015-01-09 05:37:39 -08:00
Juan Batiz-Benet 59f6cfc921 implement varints + add utp, udt 2014-11-19 13:02:06 -08:00
Juan Batiz-Benet 62a88e015e faster encapsulation + join 2014-11-05 02:30:53 -08:00
Juan Batiz-Benet 9d04132166 Split + Join 2014-11-05 02:20:27 -08:00
Juan Batiz-Benet bb34b84e84 Cast and Loopback 2014-11-05 00:04:30 -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