multiformats / rust-multiaddr

multiaddr implementation in rust
https://crates.io/crates/multiaddr
Other
86 stars 45 forks source link

Change Multiaddr internal structure to store parsed address #19

Open progval opened 7 years ago

progval commented 7 years ago

As of now, Multiaddr stores a byte array, representing the serialized version of the address.

Although this allows very fast serialization (array copy), I believe this is not the most appropriate format. Indeed, operations on Multiaddr (eg. decapsulate) actually work on the list of protocols, and not on the byte representation. The bug mentioned in PR #18 is a good example of it.

I see two possible representations:

dignifiedquire commented 7 years ago

So my goal with how it is currently stored was to have internally the same byte representation as go-multiaddr has. If we move away from that, there needs to be at least an option to get that byte representation via a method call.

From your suggestions I think I like using Vec<Addr> the best as that matches my mental representation of a multiaddr very well. What do you think?